Advertisement
Guest User

Untitled

a guest
Sep 25th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. def get_duration(start_hr, start_min, stop_hr, stop_min):
  2. total_start = (start_hr * 60) + start_min
  3. #Turn hours into minutes and adds remaining minutes to make start time
  4. total_stop = (stop_hr * 60) + stop_min
  5. #Turn hours into minutes again to make end time
  6. total_time = total_stop - total_start
  7. #final - initial for total time in minutes
  8. return total_time #return total time
  9.  
  10. def check_early(start_hr, start_min):
  11. total_start = (start_hr * 60) + start_min #covert time into minutes again
  12. if total_start < 541: # check if the time is 540 or less, 9hrs in seconds
  13. is_early = True
  14. else:
  15. is_early = False
  16. return is_early
  17.  
  18. def get_fee(duration, is_early, is_senior, has_permit):
  19. #do non dependent outcomes first,
  20. if has_permit == True:
  21. #since having a permit will negate any other values, list it first
  22. return "permit accepted."
  23. elif duration < 0:
  24. #negative duration instantly determines full price
  25. return "ticket error - pay full price, $15."
  26. elif duration < 6:
  27. #duration less than 5, instant "nocharge"
  28. return "no charge."
  29. else:
  30. extra_fee = (duration%30)
  31. if extra_fee > 0:
  32. initial_fee = ((duration//30) + 1) * 2
  33. else:
  34. initial_fee = (duration//30) * 2
  35. if initial_fee == 0:
  36. initial_fee = 2
  37. if initial_fee > 15:
  38. initial_fee = 15
  39. outcome = 0
  40. senior_discounted = False
  41. early_bird = False
  42. if is_early == True:
  43. if initial_fee > 10:
  44. initial_fee = 10
  45. early_bird = True
  46. if is_senior == True:
  47. initial_fee -= 3
  48. if initial_fee < 0:
  49. initial_fee = 0
  50. senior_discounted = True
  51. if early_bird == True:
  52. outcome = 3
  53. if senior_discounted == True:
  54. outcome = 1
  55. if early_bird == True:
  56. outcome = 2
  57. if outcome == 1:
  58. return "senior discount, pay $" + str(initial_fee) + "."
  59. if outcome == 2:
  60. return "early senior discount, pay $" + str(initial_fee) + "."
  61. if outcome == 3:
  62. return "early bird, pay $" + str(initial_fee) + "."
  63. else:
  64. return "pay $" + str(initial_fee) + "."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement