Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. """
  2. Super quiz 1.
  3. This is a module docstring in case you were wondering.
  4. Generates a helpful thank-you note based on user input.
  5. Brought to you by Daniel Petrie.
  6. """
  7.  
  8. def percent_of_goal(donation, goal):
  9. """ returns a float representing the percentage of the overall goal
  10. contributed by the donation"""
  11. percentage = donation / goal * 100
  12. return percentage
  13.  
  14. ### Don't need to include easy_donor_rank
  15.  
  16.  
  17. def donor_rank(percent_donated, amount_donated):
  18. """ takes a number and returns a rank reflective of the amount donated"""
  19. percent_donated = percentage
  20. if percent_donated <= 0 or amount_donated <= 0:
  21. return "Error"
  22. elif percent_donated < 2 and amount_donated < 500:
  23. rank = 1
  24. elif percent_donated < 2 and 500 <= amount_donated <= 1000:
  25. rank = 2
  26. elif percent_donated < 2 and amount_donated > 1000:
  27. rank = 3
  28. elif 2 <= percent_donated <= 15 and (amount_donated < 500 or 500 <= amount_donated <= 1000):
  29. rank = 2
  30. elif 2 <= percent_donated <= 15 and amount_donated > 1000:
  31. rank = 3
  32. elif percent_donated > 15 and (amount_donated < 500 or 500 <= amount_donated <= 1000):
  33. rank = 3
  34. elif percent_donated > 15 and amount_donated > 1000:
  35. rank = 4
  36. if rank == 1:
  37. return "Bronze"
  38. if rank == 2:
  39. return "Silver"
  40. if rank == 3:
  41. return "Gold"
  42. if rank == 4:
  43. return "Platinum"
  44.  
  45. def thank_donor(first_name, last_name, amount, donor_status):
  46. """prints a thank you note for anyone who donated"""
  47. print("----------------------------------------")
  48. print("Note to donor: {0}, {1}".format(last_name.upper(), first_name.capitalize()))
  49. print("----------------------------------------")
  50. print("Dear {0},".format(first_name.capitalize()))
  51. print("Thank you for your donation of ${0:.2f}".format(amount))
  52. print("to our album campaign.")
  53. print("This makes you a {0} member.".format(donor_status))
  54. print("ROCK ON,")
  55. print("Blink 992")
  56. print("========================================")
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63. def main():
  64. """ Co-ordinates the action.
  65. Should get input from user then use your other functions
  66. to do the rest.
  67. """
  68. goal = input('Pledge goal? ')
  69. goal = float(goal)
  70. first_name = input('First name? ')
  71. last_name = input('Last name? ')
  72. donation = input('Amount donated? ')
  73. donation = float(donation)
  74.  
  75. # Calls the main function to get things started
  76. main()
  77. percent_of_goal(donation, goal)
  78. donor_rank(percent_donated, amount_donated)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement