您的当前位置:首页正文

用python求正方形周长_用于正方形、矩形和ci的周长和面积的单独函数

来源:九壹网

嘿,伙计们,我对Python和一般的编码还很陌生,我想知道为什么我的代码不能工作。我一直有两个错误。我很沮丧,我已经在这干了几个小时了。谢谢

这些是我一直收到的错误。

Typeerror:**或pow()的操作数类型不受支持:“str”和“float”

Typeerror:无法将sequence乘以“str”类型的非int

我只列出userChoice1和2,因为这就是我的问题所在atm。在1) Area (Square)

2) Area (Rectangle)

3) Area (Circle)

4) Perimeter (Square)

5) Perimeter (Rectangle)

6) Perimeter (Circle)

7) Exit Program

""")

usersChoice = input (" 1,2,3,4,5,6 OR 7? ")

while usersChoice!="7":

if usersChoice == "1":

print ("You have chosen area (Square)")

length = input("input Length?")

print ("Area is:") , length**2.0

elif usersChoice == "2":

print ("You have chosen area (Rectangle)")

length = input("input length?")

width = input("input width?")

print ("Area is:") , length*width

因篇幅问题不能全部显示,请点此查看更多更全内容

Top