【发布时间】:2021-03-08 00:20:23
【问题描述】:
这是我正在打印的代码,但出现错误。类型错误:+ 的不支持的操作数类型:'float' 和 'type'
import math
def circles_of_radius():
#Prints out circumference and area with the ranged radius
for x in range(3,7):
C = (2 * math.pi * x) #calculates circumference
A = (math.pi * x**2) #calculates area
print(("A circle with radius", x) +str ("has circumference", C) +str (" and area", A))
【问题讨论】:
-
你能以清晰的方式重新添加你的代码吗?
-
我认为如果您删除元组括号并将
+str替换为,,它将起作用。所以,应该是print("radius", x, "circ", C, "area", A)。
标签: python python-3.x