1. Calculate the turnover
describe
Assuming that the sales tax rate is 6%, enter the sales amount from the keyboard to calculate the sales tax payable (with two decimal places) Be Be
Sales tax payable = sales * sales tax rate Be Be
input format
The input data should be completed in the following way, the variable name is arbitrary, and no prompt information should be added to the input() function. Be Be
Example of input method: n=input() Be Be
output format
Two decimal places can be reserved in the form {:.2f}. Be Be
For details, see the input and output examples. Be Be
Example of input and output
enter | output | |
Example 1 | 3200 |
192.00 |
Answer code:
print('{:.2f}'.format(int(input()) * 0.06))
2. Calculate the area of the rectangle
describe
Enter the length and width of the rectangle from the keyboard to find the area of the rectangle. (Requirement: The length and width of the rectangle are positive numbers, and the area result is rounded to two decimal places) Be Be
input format
The input data should be completed in the following way, the variable name is arbitrary, and no prompt information should be added to the input() function. Be Be
Enter a number on the first line, representing the length of the rectangle Be Be
Enter a number on the second line, representing the width of the rectangle Be Be
output format
Two decimal places can be reserved in the form {:.2f}. Be Be
For details, see the input and output examples. Be Be
Example of input and output
enter | output | |
Example 1 | 7.888 |
54.37 |
Answer code:
longth = float(input())
width = float(input())
S=longth*width
print(str('%0.2f'%S))
3. Calculate the area of a regular polygon
describe
A regular polygon is a polygon with equal sides and all angles are equal. Write a program that prompts the user to enter the number of sides and the side length of a regular polygon, and then calculates its area (with two decimal places) using the following formula. Description: s represents the length of the side, and n represents the number of sides. Be Be
area = (n * s²) / (4 * tan (π / n)) To To
input format
The input data should be completed in the following way, the variable name is arbitrary, and no prompt information should be added to the input() function. Be Be
Enter the first data in the first line to indicate the number of sides of a regular polygon Be Be
Enter the second data in the second line to indicate the length of the regular polygon Be Be
output format
Two decimal places can be reserved in the form {:.2f}. Be Be
For details, see the input and output examples. Be Be
Example of input and output
enter | output | |
Example 1 | 5 10 |
The positive 5 sides |
Answer code:
n=eval(input())
s=eval(input())
import math
area=(n*s**2)/(4*math.tan(math.pi/n))
print("该正5边形的面积为:",end="")
print("{:.2f}".format(area))
4. Solving for the average
describe
Suppose there are three numbers num1, num2 and num3, their values are 68, 12, 78. Find the average of these three numbers. Be Be
input format
without Be
output format
Use the basic Print format for output, see the input and output example for details Be Be
Example of input and output
enter | output | |
Example 1 | without | 52.66666666666666 |
Answer code:
Sum=68+12+78
Average=float(Sum/3)
print(Average)