Generate a Python script that simulates a basic banking system. The script should allow…
- User
Generate a Python script that simulates a basic banking system. The script should allow users to create an account, deposit money, withdraw money, and check their balance.
Outline:
- Introduction: Explain the purpose of the script and its functionalities.
- User Options:
- Provide a menu with options: Create Account, Deposit, Withdraw, Check Balance, and Exit.
- Account Management:
- Use a dictionary to store account details, including balance.
- Functions:
- Define functions for creating an account, depositing money, withdrawing money, and checking the balance.
- Input Validation:
- Validate user inputs to ensure they are correct (e.g., positive numbers for deposits/withdrawals).
- Execution Loop:
- Keep the script running until the user chooses to exit.
- Test Cases:
- Include test cases to demonstrate different functionalities.
- Error Handling:
- Gracefully handle errors, such as trying to withdraw more money than available in the balance.
- Output:
- Display outputs in the terminal.
Prompt:
Write a Python script that simulates a basic banking system. The script should provide users with the ability to create an account, deposit money, withdraw money, and check their balance.
The script should start by displaying a menu with the following options:
- Create Account
- Deposit
- Withdraw
- Check Balance
- Exit
Each function should be clearly defined:
- Create Account: Prompt the user for an account name and initialize the balance to 0.
- Deposit: Prompt the user for the account name and the amount to deposit. Update the balance accordingly.
- Withdraw: Prompt the user for the account name and the amount to withdraw. Ensure there are sufficient funds before processing the withdrawal.
- Check Balance: Prompt the user for the account name and display the current balance.
Ensure that all user inputs are validated. For example, deposits and withdrawals should be positive numbers. The script should run in a loop, allowing the user to perform multiple actions until they choose to exit.
- Assistant