Python 菜鸟在这里。我正在尝试添加在“if”语句中定义的一组输入变量,每当我尝试找到总和时,它只会显示内联值。例如,当 a、b、c 和 d 等于 5 时,周长 = 555...
shape = raw_input("Is the plot a (q) quadrilateral or (t) triangle?")
if shape.lower() == "q":
a = raw_input("What is the length in feet of side 'a'?")
b = raw_input("What is the length in feet of side 'b'?")
c = raw_input("What is the length in feet of side 'c'?")
d = raw_input("What is the length in feet of side 'd'?")
elif shape.lower() == "t":
a = raw_input("What is the length in feet of side 'a'?")
b = raw_input("What is the length in feet of side 'b'?")
c = raw_input("What is the length in feet of side 'c'?")
else:
print "Please enter 'q' for quadrilateral or 't' for triangle."
if shape.lower() == "q":
perimeter = a + b + c + d
elif shape.lower() == "t":
perimeter = a + b + c
else:
print "Please make sure you enter numbers only."
print perimeter