Share your repls and programming experiences

← Back to all posts
Automated Teller Machine
Tsadema (20)

Automated Teller Machine

more commonly known as an ATM

This is a your normal, run-of-the-mill ATM.
It functions just like in real life, except your balance doesn't save.
For example:

  • You enter your account number
  • Balance = 10
  • You withdraw 5
  • Balance = 5
  • Restart
  • You enter your account number
  • Balance = 10

I may add a saving function later.

Commentshotnewtop
LizFoster (603)

I have two suggestions for improvements to this:

  1. I had to look at the code to know what was valid as an entry; I tried a random set of numbers and it said it wasn't valid, so users can't do anything unless their entry is in the predetermined list. So instead, just allow any random set of numbers a valid bank account. This bank number shouldn't have any real relevance towards the balance, it's just for a more realistic effect.

  2. The balance is pre-determined. You could use the random module to get rid of that, by setting the balance as a random value between n1 and n2 (n1 and n2 being any numbers you wish). This would remove the need to program in balances. As far as I know this wouldn't mess up any of your code.

Hope that helps ^ ^

Tsadema (20)

@LizFoster Thanks! I'll try your suggestions.