How to use selection statements

From Computer Science Wiki
Jump to navigation Jump to search

The bank machine problem set is tricky:

# A cash machine dispenses £10 and £20 notes to a maximum of £250.
#  Write a program that shows the user
# their balance, asks them how much to withdraw, 
# ensures this is a valid amount without going overdrawn
# and with the notes available and outputs the new balance.



import os
os.system("clear")

balance = 1000
with_amount = int(input("Enter the amount you want to withdrawl" ))
if with_amount > 250:
    print("no, no, no, no....")
elif with_amount > balance:
    print("no, no, no, no....not enough in your account")
else: 
    number_of_10s = with_amount % 20
    number_of_10s = number_of_10s // 10
    number_of_20s = with_amount // 20
    print("we will give you ", number_of_10s, "10 pound notes. ")
    print("we will give you ", number_of_20s, "20 pound notes. ")