Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- Super quiz 1.
- This is a module docstring in case you were wondering.
- Generates a helpful thank-you note based on user input.
- Brought to you by Daniel Petrie.
- """
- def percent_of_goal(donation, goal):
- """ returns a float representing the percentage of the overall goal
- contributed by the donation"""
- percentage = donation / goal * 100
- return percentage
- ### Don't need to include easy_donor_rank
- def donor_rank(percent_donated, amount_donated):
- """ takes a number and returns a rank reflective of the amount donated"""
- percent_donated = percentage
- if percent_donated <= 0 or amount_donated <= 0:
- return "Error"
- elif percent_donated < 2 and amount_donated < 500:
- rank = 1
- elif percent_donated < 2 and 500 <= amount_donated <= 1000:
- rank = 2
- elif percent_donated < 2 and amount_donated > 1000:
- rank = 3
- elif 2 <= percent_donated <= 15 and (amount_donated < 500 or 500 <= amount_donated <= 1000):
- rank = 2
- elif 2 <= percent_donated <= 15 and amount_donated > 1000:
- rank = 3
- elif percent_donated > 15 and (amount_donated < 500 or 500 <= amount_donated <= 1000):
- rank = 3
- elif percent_donated > 15 and amount_donated > 1000:
- rank = 4
- if rank == 1:
- return "Bronze"
- if rank == 2:
- return "Silver"
- if rank == 3:
- return "Gold"
- if rank == 4:
- return "Platinum"
- def thank_donor(first_name, last_name, amount, donor_status):
- """prints a thank you note for anyone who donated"""
- print("----------------------------------------")
- print("Note to donor: {0}, {1}".format(last_name.upper(), first_name.capitalize()))
- print("----------------------------------------")
- print("Dear {0},".format(first_name.capitalize()))
- print("Thank you for your donation of ${0:.2f}".format(amount))
- print("to our album campaign.")
- print("This makes you a {0} member.".format(donor_status))
- print("ROCK ON,")
- print("Blink 992")
- print("========================================")
- def main():
- """ Co-ordinates the action.
- Should get input from user then use your other functions
- to do the rest.
- """
- goal = input('Pledge goal? ')
- goal = float(goal)
- first_name = input('First name? ')
- last_name = input('Last name? ')
- donation = input('Amount donated? ')
- donation = float(donation)
- # Calls the main function to get things started
- main()
- percent_of_goal(donation, goal)
- donor_rank(percent_donated, amount_donated)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement