Im attempting to write a code where the user if prompted for todays date and their birthdate in order to determine their age. The age will determine how much their ticket price will be. It would ask if the customer has a coupon, which would take off one dollar off their price. I have come up with this so far:
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("Today's date: (mm dd yyyy)")
Todays_date = input("--->")
from datetime import date
def calculate_age(born):
Todays_date = date.today()
return today.year - born.year - ((today.month, today.day) < (born.month, born.day))
if age <= 14:
price==5.00
elif age > 15 and age < 64:
price==9.00
elif 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))
I was looking at some similar questions and I they helped solve some of my problems but I am not sure what to define 'age' as so that the program will read it.
So after looking at the responses would it look more like this?
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("Today's date: (mm dd yyyy)")
Todays_date = input("--->")
from datetime import date
def calculate_age(born):
today = date.today()
return today.year - born.year - ((today.month, today.day) < (born.month, born.day))
age = calculate_age(Date_of_birth)
if age <= 14:
price==5.00
elif age > 15 and age < 64:
price==9.00
elif 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))