python windows 7 python 3.3.0的新手我不知道如何返回函数参数值。一直在疯狂地环顾四周,这是一项课堂作业,但我确实有一个简单的脚本可以上交,但我正在拍摄以推动我自己。只需要知道我是否走错了方向。谢谢
def main():
seat_a = 15.00
seat_b = 12.00
seat_c = 9.00
class_a(seat_a)
class_b(seat_b)
class_c(seat_c)
set_a = class_a(ticket_a)
set_b = class_b(ticket_b)
set_c = class_b(ticket_c)
result_a_b_c = set_a + set_b + set_c
print("The total income generated from all ticket sales is $ ", format(result_a_b_c,',.2f'))
def class_a(ticket_a):
while True:
try:
ask_a = float(input("How many class A seat tickets were sold? "))
total_a = ticket_a * (ask_a)
break
except ValueError:
print("That is not a valid number. Please try again.")
class_a(ticket_a)
break
total_a = class_a(ticket_a)
def class_b(ticket_b):
while True:
try:
ask_b = float(input("How many class B seat tickets were sold? "))
total_b = ticket_b * (ask_b)
break
except ValueError:
print("That is not a valid number. Please try again.")
class_b(ticket_b)
total_b = class_b(ticket_b)
break
def class_c(ticket_c):
while True:
try:
ask_c = float(input("How many class C seat tickets were sold? "))
total_c = ticket_c * ask_c
break
except ValueError:
print("That is not a valid number. Please try again.")
class_c(ticket_c)
total_c = class_c(ticket_c)
break
main()