我已經嘗試了一切。在python小提琴在線測試。這個盡我所能,它的工作原理,但不會循環,我可以按任何超過5退出/得到感謝您使用jys區域計算器。如何保持程序運行,直到選擇退出選項
print "Welcome to Jys area calculator!"
print "What is your name?"
name = raw_input()
print "Hi",name, ",please select a formula using the letter it represents or press 6 to quit. Your options are:"
mylist = ['1 for square', '2 for rectangle', '3 for circle', '4 for triangle','5 for elipse']
for elem in mylist:
print elem
shape = input()
if shape == 1:
print "Okay",name, ",to work out area of square first enter length and then breadth of square"
a = input()
b = input()
c=a*b
print "The area of your square is",c
elif shape == 2:
print "Okay",name, ",to work out area of rectangle first enter length and then breadth of rectangle"
a = input()
b = input()
c=a*b
print "The area of your rectangle is",c
elif shape == 3:
print "Okay",name, ",to work out area of a circle enter the radius"
r= input()
c= 3.14159265359*(r*r)
print "The area of your circle is",c
elif shape == 4:
print "Okay",name, ",to work out area(c) of triangle first enter height(h) then base(b) length"
h= input()
b= input()
c=0.5*h*b
print "The area of your triangle is",c
elif shape== 5:
print "Okay",name, ",to work out area of ellipse first enter length then breadth."
a= input()
b= input()
c= 3.14159265359*a*b
print "The area of your elipse is",c
else:
print "Thank you for using Jys area calculator",name,"!"
你想達到什麼目的?我想'loop'是你的意思,腳本在計算後重新運行? – ppasler