An-Hui Engineering University
Python programming test report
Class: Logistics 191 Name: Yujia student number: 3190505116 grades:
Date: 2020/3/22 Instructor: Yu Xiu
Experiment name: Structured Programming sequence (confirmatory test)
Purpose:
1. A method of data input and output control
2. familiar with the structure of the program in the order of execution of sentence
3. master the design of the sequence structure of the program
Experimental conditions:
PC or remote programming environment
Experiment:
Completion of three programming problems. (Python123)
1. Calculation circular area S
Problem Description:
The calculated area of a circle radius of the circle, radius 25. Please write and run the following code:
radius = 25 # 25 is the radius of a circle
area = 3.1415 * radius * radius # circular area is calculated according to the formula
print ( "{:. 2f}". format (area)) # outputs only two decimal places the result
input Output:
Input: None Output: 1963.44
2. The sum
Problem Description:
Programming, input from the keyboard two numbers x, y, find x, y and assigned to the sum of s, the final output s.
input Output:
3. The volume of a sphere seek
Problem Description:
Enter the radius of the sphere, the sphere volume calculation.
input Output:
Input: A positive number
Output: the volume of the ball, as a result two decimal places
Experiment recording and analysis:
(Please fill in the experimental recording and analysis results)
1. Calculation circular area S
Written procedures are as follows:
Output:
2. The sum
Written procedures are as follows:
Output:
3. The volume of a sphere seek
Written procedures are as follows:
Output:
Questions:
(Be careful not to leak A)
Questions 1. What impact factor calculation accuracy problems and 3? How to make a value of 1 and 3 to get a more accurate? (You can try on the local computer, or self-programmed on python123)
1 and 3 issues affecting title to calculate the accuracy of factors:
① number of decimal places to retain enough influence accuracy of the results.
② accuracy values affect the results of Π.
③ operation exists between the floating-point mantissa uncertainty, uncertainty mantissa in many programming languages exist, related to the operation of the computer's internal digital implementation principle, all the numbers in a computer using binary representation, the binary representation of the decimal, decimal fractions can be infinitely close but not identical, therefore it affects the accuracy of the results.
④ computer to conduct mutual conversion between decimal and binary output of the operational result before the result may be infinitely close to the exact value, because there may be uncertainty mantissa affect the accuracy of the results.
So that a more accurate value of 1 and 3 were:
1. Question 1
① Increase Decimal reserved
② increase in the median value of Π
③ increase the value of the median number of decimal places and retention of Π
The results can be seen in three cases: 1963.43750,1963.50,1963.49538 quite different with the results of the first run of the fractional portion of 1963.44.
2. Question 3
① Increase Decimal reserved
② increase in the median value of Π
③ increase the value of the median number of decimal places and retention of Π
The results can be seen in three cases: 4.18867,4.19,4.18879, except as in the case with the results of the first two runs of 4.19, the other with a fractional part of the result of the first-run results are quite different.