在python中获取repatted生成的答案

时间:2017-09-10 16:37:18

标签: python-3.x math

我正在尝试创建一个可以帮助我使用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

1 个答案:

答案 0 :(得分:0)

您不需要将pi强制转换为字符串。这样做会重复字符串

试试这个

from math import pi
R = float(input("enter a radius: "))
A = pi * (R**2)