自己写的计算圆代码
print('''
1.输入半径求圆周长
2.输入直径求圆周长
3.输入半径求圆面积
4.双圆
''')
while True:
try:
number = int(input("请输入序号:"))
if number == 1:
circumference_R = int(input("请输入圆半径:"))
result_one = 2 * 3.14 * circumference_R
print(result_one)
qu1 = input('是否除2?N/Y:')
if qu1 == "Y" or qu1 == "y":
qu1_1 = result_one / 2
qu1_1_1 = result_one / 2 + 2 * circumference_R
print(qu1_1,"加上直径:",qu1_1_1)
elif number == 2:
circumference_D = int(input("请输入圆直径:"))
result_two = 3.14 * circumference_D
print(result_two)
qu2 = input('是否除2?N/Y:')
if qu2 == "Y" or qu2 == "y":
qu2_1 = result_two / 2
qu2_1_1 = qu2_1+ circumference_D
print(qu2_1,"加上直径:",qu2_1_1)
elif number == 3:
area_R = int(input("请输入圆半径:"))
result_three = area_R * area_R * 3.14
print(result_three)
qu_3 = input('是否除2?N/Y:')
if qu_3 == "Y" or qu_3 == "y":
qu3_1 = result_three / 2
print(qu3_1)
elif number == 4:
circumference_R_1 = int(input("请输入大圆半径:"))
circumference_r_1 = int(input("请输入小圆半径:"))
circumference_Rr_1 = circumference_R_1 + circumference_r_1
result_four = circumference_Rr_1 * circumference_Rr_1 * 3.14 - circumference_r_1 * circumference_r_1 * 3.14
print(result_four)
except ValueError:
print("请输入正确的数字")
else:
print("使用完成")