我正在尝试制作一个计算入场费用的程序。我已经设法做到了,除了一个需要两个成人和三个孩子的部分,那么费用是 15 美元。这是否应该使用 if 语句来完成,我该怎么做?
import math
loop = 1
choice = 0
while loop == 1:
print "Welcome"
print "What would you like to do?:"
print " "
print "1) Calculate entrance cost"
print "2) Leave swimming centre"
print " "
choice = int(raw_input("Choose your option: ").strip())
if choice == 1:
add1 = input("Adults: ")
add2 = input("Concessions: ")
add3 = input("Children: ")
print add1, "+", add2, "+", add3, "answer=", add1 *5 + add2 *3 + add3 *2
elif choice == 2:
loop = 0
提前感谢您的任何帮助,我们将不胜感激!!