我正在尝试创建一个可以帮助我使用Radius查找Area的程序。但它的输出很奇怪,看一看!
Pi = 3.1415929203539825
print('What is the Radius') #asking for Radius
R = input()
A = str(Pi) * int(R) * int(R)
print("The Area of this circle will be " + str(A) + "")
当R = 5时,这就是它输出的内容:
3.14159292035398253.14159292035398253.14159292035398253.14159292035398253.14159292035398253.14159292035398253.14159292035398253.14159292035398253.14159292035398253.14159292035398253.14159292035398253.14159292035398253.14159292035398253.14159292035398253.14159292035398253.14159292035398253.14159292035398253.14159292035398253.14159292035398253.14159292035398253.14159292035398253.14159292035398253.14159292035398253.14159292035398253.1415929203539825
答案 0 :(得分:0)
您不需要将pi强制转换为字符串。这样做会重复字符串
试试这个
from math import pi
R = float(input("enter a radius: "))
A = pi * (R**2)