def distribute_notes(withdrawal_amount): # List of available notes in the ATM available_notes_at_atm = [200, 100, 50, 20, 10] # List with the value of the note and the available quantity total_available_notes_per_note = [(200, 500), (100, 2000), (50, 5000), (20, 10000), (10, 10000)] used_notes = [] # Check if the withdrawal is valid (minimum of 10 dollars and multiple of 10) if withdrawal_amount < 10 or withdrawal_amount % 10 != 0: return "Invalid withdrawal amount. The withdrawal must be at least 10 dollars and multiple of 10." # Limit 10 dollars notes for withdrawals below 100 dollars if withdrawal_amount < 100: max_10_dollars_notes = 3 else: max_10_dollars_notes = 0 for note_value, available_quantity in total_available_notes_per_note: # Limit the use of 10 dollars notes if note_value == 10 and len(used_notes) >= max_10_dollars_notes: continue while withdrawal_amount >= note_value and available_quantity > 0: used_notes.append(note_value) withdrawal_amount -= note_value available_quantity -= 1 if withdrawal_amount != 0: return "It's not possible to withdraw this amount with the available notes." else: return used_notes response = 'yes' balance = 2500 while response == 'yes': withdrawal_amount = int(input("How much do you want to withdraw? ")) if withdrawal_amount <= balance: balance = balance - withdrawal_amount print(f"Current balance is: {balance}") else: print("Unauthorized operation") response = input("Do you want to perform another operation? [yes/no] ")
deanhystad write Mar-22-2024, 05:05 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.