Python programming lab report four: loop structure

An-Hui Engineering University

  Python programming  test report

Class    Logistics 191    Name   Ni Shaolei school number  3190505131  scores            

Date    2020.4.9     instructor        repair buildings    

[Name] experiment experimental four-cycle structure of the program design (design type test)

 

【Purpose】  

(1) be familiar with methods to achieve while and for loop statement;

(2) control method used in a programming cycle implement algorithms

 

[Experiment Conditions]  

PC or remote programming environment

 

[Experimental] content

(1) Calculate the value of base e

Problem Description:

 e is sometimes called natural constant (Natural constant), is approximately equal to the 2.71828182845904523536 ...... irrational number.

Use the following formula to find the number of base e of natural logarithm approximation.

e = 1 + 1/1! +1/2! ... + 1 / n! 

Cycle program can be designed, an absolute value is determined until the last stop of less than 10 -6 power cycle, as noted calculation error reason, different methods may differ slightly.

 

(2) determining the number of daffodils

Problem Description:

        Narcissistic number (Narcissistic number) is also known as super does not fully digital variable, the number of narcissism, since a power of Armstrong Armstrong number or number (Armstrong number),

Refers to a number of 3-digit daffodils, its number of bits on each of the third power is equal itself (eg: 5 + 1 ^ 3 ^ 3 ^ 3 + 3 = 153).

Design cycle program, enter a three-digit integer, determine whether the number of daffodils, narcissus if the number is, the output "is the number of Narcissus", otherwise output "is not the number of Narcissus."

 

(3) N multiple party 

Problem Description:

        Write a program to calculate the input power of 0 to 5 the number N of power results, and sequentially outputs the results of the 6, between the output separated by spaces. Where: N is a floating point number.

print () function may output a plurality of information simultaneously, by the following method may be used for a plurality of spaces divided output:

print(3.14, 1024, 2048)

 

[Experimental recording and analysis]

(Please fill in the experimental records and analysis results)

(1) Calculate the value of base e

 

 

2. determine the number of daffodils

 

 

 3.N multiple parties

 

 

 

 

[Questions]

      What is the number of cycles in the loop structure is dependent?

1) for loop structure is determined by the structure of convenience

2) while infinite loop

3) break their word and continue to retain influence from

 

Guess you like

Origin www.cnblogs.com/NSL2333/p/12664375.html