1. Or find the average
describe
Input the values of three numbers num1, num2 and num3 from the keyboard, solve the average of these three numbers and output the three numbers. Be Be
input format
The variable name of the input data is arbitrary, and no prompt information should be added to the input() function. Be Be Be Be
Such as: num1=input()
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 | 56,78,16 |
num1= 56 num2= 78 num3= 16 Average: 50.0 |
Answer code:
s = input()
l = s.split(',')
n1 = int(l[0])
n2 = int(l[1])
n3 = int(l[2])
print("num1= "+str(n1)+" num2= "+str(n2)+" num3= "+str(n3)+" 平均值: {:.1f}".format((eval(str(n1))+eval(str(n2))+eval(str(n3)))/3))
2.
Calculate the area and perimeter of a circle
describe
Enter the radius value of the circle from the keyboard to find the area and perimeter of the circle. (Requirement: The radius value is an integer, 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
Example of input method: r=input() Be Be
output format Be
Use the .format format to output the area with two decimal places. For details, see the input and output examples. Be Be
Example of input and output
enter | output | |
Example 1 | 46 | Circle Area: 6647.61, Circle Length: 289.03 |
Answer code:
import math
r=float(input())
p=2*math.pi*r #圆的周长
s=math.pi*r**2 #圆的面积
print("圆面积:{:.2f}".format(s)+",圆周长:{:.2f}".format(p))