The Account Manager
A easy Python mock interview question on DataDriven. Practice with AI-powered feedback, real code execution, and a hire/no-hire decision.
- Domain
- Python
- Difficulty
- easy
- Seniority
- L4
Interview Prompt
You're replaying a checking account's transaction log. Implement a `BankAccount` class that opens at `initial_balance`, grows on a deposit, and shrinks on a withdrawal but refuses any withdrawal larger than the current balance. An `['undo']` reverses the most recent deposit or withdrawal that is still standing, so several undos in a row peel back that many transactions, while a balance read or an undo with nothing left to reverse changes nothing. Drive it from `bank_account_simulator(initial_balance, ops)`, which applies each op (`['deposit', amt]`, `['withdraw', amt]`, `['undo']`, or `['balance']`) in order and returns the closing balance, or the string `'ValueError'` the moment a withdrawal tries to pull more than the account holds.
Summary
Deposits, withdrawals, and a ledger you can walk back.
How This Interview Works
- Read the vague prompt (just like a real interview)
- Ask clarifying questions to the AI interviewer
- Write your python solution with real code execution
- Get instant feedback and a hire/no-hire decision