Experimental five-cycle structure programming

Python programming  experiment report

Class    Logistics 192    Name Tao Jun  Student Number  3190505235  Results                   

Date      2020.4.22     instructor  repair buildings        

 

 

 

 

 

Experiment 5: Comprehensive use of three basic structures for programming (comprehensive experiment) (two hours)

 【Purpose】  

(1) Further master the methods and skills of selection and cyclic structure programming;

(2) Comprehensive use of three basic structures for program design;

【Experimental conditions】  

PC or remote programming environment

【Experiment content】

1. Complete three programming questions.

1) Calculate and output the prime numbers in the specified range

     Prime numbers are also called prime numbers. Refers to an integer in a natural number greater than 1, in addition to 1 and the integer itself, can not be divided by other natural numbers. In other words, a natural number with only two positive factors (1 and itself) is a prime number. Numbers greater than 1 but not prime are called composite numbers. 1 and 0 are neither prime nor composite. Prime numbers play an important role in number theory. More than 2300 years ago, the ancient Greek mathematician Euclid proved in the book Geometry Originals that there are an infinite number of prime numbers, such as 2, 3, 5, 7, 11, and so on.

description:

 programming primes within specified output range, separated by commas input, output by spaces. The specified range is specified by user input. 

2) Nine nine multiplication table

description

      Please design a "nine nine multiplication table" in the following format and print it out.


 

Programming highlights and tips ‪‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‪‬

1. Use a for loop or a while loop to achieve the above functions

2. The amount of code does not exceed 10 lines ‮‬‭‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‪‬‬‬‪‬‪

3. Use a tab "\ t" to separate each equation in a line; ‪‬‪‬‪‬‪‬‪‬‮‬‭‬‫‬‪‬‪‬‪‬‪‬‪‪‪ ‬‫‬

    For each line equation between print () print character space is achieved in that ‬‪‬‪‬‪‬‪‬‮‬‭‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬ ‬‪‬‬‬‬‬‬‬‬‬‬‬‬

     print("")

 

3) Count the number of different characters

description

The user enters a line of characters from the keyboard. Please write a program to count and output the number of English characters, numbers, spaces and other characters. ‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‫‬

‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‫‬ input format

     Enter a line of characters

Output: output the number of letters, numbers, spaces, and other characters in order, separated by spaces

Such as:


【Experimental record and analysis】

(Please fill in the experimental records and analysis results)

1) Calculate and output the prime numbers in the specified range

code show as below:

Experiment process error:

1. The else line of the seventh line is aligned with the if

Show as below

 

 

2. The quotes after "end" have no spaces

The results are shown below with no gaps between the results

2) Nine nine multiplication table

 

 

When the problem occurs during operation, there is     no space before the end, which leads to an inconsistent interval between the answer and the operation result.

 

3) Count the number of different characters

The problem is    that the code characters before and after the code are inconsistent

As follows

 

Guess you like

Origin www.cnblogs.com/TAJU1002/p/12757579.html