Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_duration(start_hr, start_min, stop_hr, stop_min):
- total_start = (start_hr * 60) + start_min
- #Turn hours into minutes and adds remaining minutes to make start time
- total_stop = (stop_hr * 60) + stop_min
- #Turn hours into minutes again to make end time
- total_time = total_stop - total_start
- #final - initial for total time in minutes
- return total_time #return total time
- def check_early(start_hr, start_min):
- total_start = (start_hr * 60) + start_min #covert time into minutes again
- if total_start < 541: # check if the time is 540 or less, 9hrs in seconds
- is_early = True
- else:
- is_early = False
- return is_early
- def get_fee(duration, is_early, is_senior, has_permit):
- #do non dependent outcomes first,
- if has_permit == True:
- #since having a permit will negate any other values, list it first
- return "permit accepted."
- elif duration < 0:
- #negative duration instantly determines full price
- return "ticket error - pay full price, $15."
- elif duration < 6:
- #duration less than 5, instant "nocharge"
- return "no charge."
- else:
- extra_fee = (duration%30)
- if extra_fee > 0:
- initial_fee = ((duration//30) + 1) * 2
- else:
- initial_fee = (duration//30) * 2
- if initial_fee == 0:
- initial_fee = 2
- if initial_fee > 15:
- initial_fee = 15
- outcome = 0
- senior_discounted = False
- early_bird = False
- if is_early == True:
- if initial_fee > 10:
- initial_fee = 10
- early_bird = True
- if is_senior == True:
- initial_fee -= 3
- if initial_fee < 0:
- initial_fee = 0
- senior_discounted = True
- if early_bird == True:
- outcome = 3
- if senior_discounted == True:
- outcome = 1
- if early_bird == True:
- outcome = 2
- if outcome == 1:
- return "senior discount, pay $" + str(initial_fee) + "."
- if outcome == 2:
- return "early senior discount, pay $" + str(initial_fee) + "."
- if outcome == 3:
- return "early bird, pay $" + str(initial_fee) + "."
- else:
- return "pay $" + str(initial_fee) + "."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement