我正在尝试设计一个程序,您可以根据年龄计算门票价格。价格为:14 岁及以下(5.00 美元)、15 至 64 岁(9.00 美元)和 65 岁及以上(7.50 美元)。顾客还可能有一张优惠券,可以从他们的价格中扣除一美元。到目前为止我已经想出了:
print ("Hello, welcome to Hopper's Computer Museum! To determine your enterance fee, please enter the following:")
print ('Your Date of Birth (mm dd yyyy)')
Date_of_Birth = input("--->")
print ('Todays Date: (mm dd yyyy)')
Todays_Date = input("--->")
age = (tYear-bYear)
if (bMonth > tMonth):
age == age-1
if (bMonth == tMonth and
bDay > tDay):
age == age-1
price = -1
while price == -1:
try:
age = int(input('age:'))
excpet ValueError:
print("Not a number, try again.")
continue
if age <= 14:
price==5.00
elif age > 15 and age < 64:
price==9.00
else age > 65:
price==7.50
print ('Do you have a coupon (y/n)?')
Discount = input("--->")
if Discount == "y" or Discount == "Y":
price = price-1
elif Discount == "n" or Discount == "N":
price = price
print ('Your admission fee is '+str(price)')
我感到困惑的一件事是如何让 Python 获取用户输入的日期并将其放入我设置的年龄计算中。
我是一名优秀的程序员,十分优秀!