Pythons Project for beginners - Post 33: Simple ATM Simulator
- Anubhav Somani
- Sep 6
- 2 min read

Let's build a Simple ATM (Automated Teller Machine) Simulator. This project is a great way for beginners to practice using functions, loops, and managing a state (like an account balance) throughout the program.
First, here is the explanation of how the project is built.
How the "Simple ATM Simulator" is Made
The Core Idea: The goal is to create a command-line program that mimics the basic functions of an ATM. A user will be able to check their account balance, deposit money, and withdraw money.
Managing the Account Balance: The most important piece of data is the user's account balance. We'll start by initializing a variable, balance, to a starting value (e.g., 1000.0). This variable will be updated by the deposit and withdraw functions.
A Menu-Driven Interface: To allow the user to perform multiple actions, we'll use a while True loop. This creates an infinite loop that constantly displays a menu of options to the user:
Check Balance
Deposit
Withdraw
Quit The loop will only stop when the user chooses the "Quit" option.
Organizing with Functions: To keep the code clean and easy to understand, we'll break down each ATM action into its own function.
check_balance(current_balance): A very simple function that takes the current balance as an argument and prints it in a formatted string.
deposit(current_balance): This function will ask the user how much they want to deposit. It uses a try-except block to make sure the input is a valid number. It then adds the amount to the balance and returns the new balance.
withdraw(current_balance): This function asks for the withdrawal amount. It includes logic to check two things: if the amount is positive, and if the user has enough funds in their account. If the withdrawal is valid, it subtracts the amount and returns the new balance; otherwise, it prints an error message.
Handling User's Choice: Inside the main while loop, we'll use an if/elif/else structure to call the correct function based on the user's menu choice. If the user enters an invalid option, the else block will catch it and show an error message. When the user chooses to quit, we use the break keyword to exit the loop and end the program.



Comments