1) Area (Square)
2) Area (Rectangle)
3) Area (Circle)
4) Perimeter (Square)
5) Perimeter (Rectangle)
6) Perimeter (Circle)
7) Exit Program
""")
Choice = input ("1,2,3,4,5,6 OR 7? ")
while True:
if Choice == "1":
print ("You have chosen area (Square)")
length = float(input("input Length?"))
print ("Area is:" , length**2.0)
elif Choice == "2":
print ("You have chosen area (Rectangle)")
length = float (input("input length?"))
width = float (input("input width?"))
print ("Area is:" , length*width)
elif Choice == "3":
print ("You have chosen area (Circle)")
radius = float (input("input radius?"))
print ("Area is:" , (radius**2.0)*3.14)
elif Choice == "4":
print ("You have chosen perimeter (Square)")
length = float(input("Input length?"))
print ("Perimeter is:" , length*4.0)
elif Choice == "5":
print ("You have chosen perimeter (Rectangle)")
width = float(input("Input width?"))
length = float(input("Input length?"))
print ("Perimeter is:" , width*2.0+length*2.0)
elif Choice == "6":
print ("You have chosen perimeter (Circle)")
radius = float(input("Input radius?"))
print ("Perimeter is:" , 2.0*3.14*radius)
elif Choice == "7":
print ("You have chosen to exit")
exit()
break
答案 0 :(得分:2)
你的休息是在循环结束时,所以这就是你告诉程序要做的事情:
while True:
//Choice stuff
exit the loop
将break
和exit()
移到elif Choice == "7":
内,只有在选择了选项7时才会执行该代码。
您实际上只需要一个转义功能。我倾向于不使用exit()
而只使用break
- 如果这是程序的结束,它将会退出。如果您有下面的代码,它将被执行。好的做法是保持一致。
答案 1 :(得分:1)
但是你必须将@Override
public boolean onMarkerClick (Marker marker) {
Model hotelModel = markerMap.get(marker);
if(hotelModel != null) {
Log.d("test", "Hotel "+hotelModel.getTitle()+" is clicked");
}
}
放入exit
声明中。并且else
不是必需的。