Answer to Question #317934 in Python for mike

Question #317934

A certain charity designates donors who give $10,000.00 or more as

Benefactors; those who give $1,000.00 or more but less than $10,000.00 as

Patrons; those who give $200.00 or more but less than $1,000.00 as Supporters;

those who give $15.00 but less than $200.00 as Friends; and those who give

less than $15 as Cheapskates.

Write a program containing a nested if-else statement (or statements) that,

given a keyboard input with the amount of a contribution, outputs the correct

designation for that contributor.

Here’s an example that illustrates what your program should look like in

action:

~/ python donor.py

Enter the amount of a contribution: $5.20

Cheapskate!

Test your program also for the input values: 10000.00, 1000.00,

999.99, 12200.00,15.00, 499.99, 2200.00, 199.99, 75.33

An appropriate error message should be output (and your program should halt) when

an amount less than 0 is input.


1
Expert's answer
2022-03-25T04:37:15-0400
contr = float(input("Enter amount of a contribution: "))
print()
print("Contributor: ", end="")
if contr >= 10000:
    print("Benefactor")
elif (contr >= 1000) & (contr < 10000):
    print("Patron")
elif (contr >= 200) & (contr < 1000):
    print("Supporter")
elif (contr >= 15) & (contr < 200):
    print("Friend")
elif contr < 0:
    print("Error - amount less than 0")
else:
     print("Cheapskate")

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS