Solution Exercise 6

It is common for images of a country’s previous leaders, or other individuals of historical significance, to appear on its money. The individuals that appear on banknotes in the United States are listed in the table below.
Write a program that begins by reading the denomination of a banknote from the user. Then your program should display the name of the individual that appears on the banknote of the entered amount. An appropriate error message should be displayed if no such note exists.

Individual Amount
George Washington $1
Thomas Jefferson $2
Abraham Lincoln $5
Alexander Hamilton $10
Andrew Jackson $20
Ulysses S. Grant $50
Benjamin Franklin $100

Hint:
While two dollar banknotes are rarely seen in circulation in the United States, they are legal tender that can be spent just like any other denomination. The United States has also issued banknotes in denominations of $500, $1,000, $5,000, and $10,000 for public use. However, high denomination banknotes have not been printed since 1945 and were officially discontinued in 1969. As a result, we will not consider them in this exercise. The solution given will use a dictionary. If you are not familiar with the use of dictionaries you should wait with this exercise until you are.

 

def main():
    notes = {"1"  : "George Washinton",
             "2"  : "Thomas Jefferson",
             "5"  : "Abraham Lincoln",
             "10" : "Alexander Hamilton",
             "20" : "Andrew Jackson",
             "50" : "Ulysses S. Grant",
             "100": "Benjamin Franklin"}
    
    value = input("Please enter the value of an US dollar note: ")
    if value not in notes:
        print("Sorry that is not a valid US dollar note")
    else:
        print("On that note you will find", notes[value])

           
if __name__ == '__main__':
    main()