所以今天在科学课上我想到为四边形的基本边界制作一个python脚本。将来以后我想扩展到圆形和其他形状,但我陷入了错误。请帮忙。
我的代码:
bList
输出很时髦。如果print ("This is a program to find the perimeter of a quadrilateral. Input the length and breath and get the desired perimeter")
len = input("What is the length?")
bre = input("What is the breath?")
length = len + len
breath = bre + bre
perimeter = length + breath
print ("The perimeter of the quadrilateral is :" + perimeter)
和l=2
则输出为b=1
。
另外,如何将其扩展为不同的形状?我正在考虑使用if和else选项2211
然后执行循环代码if choice = circle
然后执行三角形代码。有没有人有更好的主意?
答案 0 :(得分:0)
请记住转换数据类型
print ("This is a program to find the perimeter of a quadrilateral. Input the length and breath and get the desired perimeter")
len = input("What is the length?")
bre = input("What is the breath?")
len=int(len)
bre=int(bre)
length = len + len
breath = bre + bre
perimeter = length + breath
print ("The perimeter of the quadrilateral is :" + str(perimeter))