Python (Fall 2026) Module 7-1: Reviewing the ATM Assignment
Watch on YouTube →
Overview
Bill Moseley reviews a Python ATM assignment built around checking and savings balance variables, a `while True` transaction loop, and menu choices for depositing, withdrawing, or checking balances. He demonstrates account selection with `if/elif/else`, formatted currency output, and withdrawal checks, then identifies usability improvements such as re-prompting after invalid input and using a dictionary to support additional accounts.
Key takeaways
- A `while True` loop can keep an ATM transaction menu running until the user declines another transaction, at which point `break` exits the loop.
- Normalize account input with `.strip().lower()` before comparing it with `c` or `s`, and convert the amount input to a float only after applying string methods.
- Check that an account balance is greater than or equal to the requested withdrawal before subtracting, so the transaction cannot overdraw the account.
- Formatted f-strings with two decimal places keep currency output consistent, while aligned labels and amounts make checking and savings balances easier to compare.
- Duplicating the checking logic for savings is workable for a two-account assignment, but a dictionary could support additional accounts without adding another hard-coded balance variable.
- The assignment's core evaluation priorities are correct indentation, coherent control flow, appropriate `if/elif/else` branches, and comments.
Chapters
- The program stores starting amounts in the float variables `flSavingsBalance` and `flCheckingBalance`; balances reset each time the program runs.
- A `while True` loop presents menu options for deposit, withdrawal, and balance checks, and `break` exits when the user declines another transaction.
- Menu input outside choices 1, 2, or 3 produces an invalid-choice message before the program asks whether to continue.
- The deposit flow uses `input().strip().lower()` to normalize the account choice, then `if/elif/else` accepts checking (`c`) or savings (`s`).
- The deposit amount is converted to a float, added to the selected balance with `+=`, and displayed along with the new balance to two decimal places.
- A test exposed a misplaced `.strip()` call on a float; applying `.strip()` to the input before `float()` fixed the error.
- The savings deposit branch reuses the checking logic, changing the account variable and displayed account name.
- The withdrawal flow reuses the account-selection structure and asks for a withdrawal amount, storing it in `flWithdraw`.
- Before subtracting, the program compares the selected balance with the requested amount; if funds are insufficient, it prints an error instead of updating the balance.
- Successful withdrawals use `-=`, report the amount and account, and print the updated balance; separate checking and savings branches point to their respective variables.
- Moseley tests a $200 withdrawal from an account holding about $100 and confirms that the insufficient-funds check prevents the transaction.
- The balance report prints checking and savings on separate lines, using `ljust()` for labels and formatted f-strings to align dollar amounts with two decimal places.
- Testing covers deposits, balance checks, successful withdrawals, and an attempted overdraft; an invalid account choice currently forces the user back through the main menu.
- A usability improvement would re-prompt for a valid account rather than making users restart the transaction flow.
- For the assignment baseline, Moseley emphasizes clear indentation, sensible `if/elif/else` structure, and comments; a dictionary could replace the two hard-coded variables and allow accounts to be added dynamically.
Transcript excerpt
0:01 Okay. So, I want to, I want to review some of assignment six, because I know it was a pretty big step up in terms of not necessarily difficulty, because we've sort of been building stuff that has, we've used all of this stuff. We've used if, we've used while, we've used these things, but what we haven't done is use them in a program that has this many parts to it. And I know that by itself can give you some difficulties. And so I'm going to run through this, and then I'm actually gonna code out, I probably won't code out everything, but I'm going to sort of show you how I would approach it. And if you start with this template code, that's by far the easiest way to go. If you want to challenge yourself and start from scratch,
0:52 I always encourage you to challenge yourself. But using this code is totally fine also. So, we've got the two variables up at the top, flSavingsBalance and flCheckingBalance. Both of those are floats. I've put some money in the account to start with. And so those are going to represent our accounts throughout the whole program. So, as we add money to our account or take money out of our account, we're going to add and subtract from, from those variables to keep track of how much money we have. Obviously, every time I run this program, I'm going to start over at these amounts. It doesn't save. So, that's a flaw that we wouldn't expect to be present if it was some kind of a real financial accounting program. That would be totally useless.
1:43 But for the purpose of this, we're just learning how to use these structural elements. So, we've got this, we got a little welcome here, and then we jump straight into what you might call the
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Bill Moseley, Ph.D. - Computer Science Educator.