Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- class BankingSystem:
- def __init__(self):
- self.bankingAsystem = {"12345": ["Shola", 100], "10002": ["Nadav", 200], "10003": ["MOhamad", 10]}
- def createNewAccount(self):
- name = input("Enter your name: ")
- initialDeposit = float(input("How much money would you like to deposit: "))
- while True:
- accessNumber = random.randint(00000, 99999)
- if accessNumber not in self.bankingAsystem.keys():
- self.bankingAsystem[accessNumber] = [name, initialDeposit]
- break
- print("your account number is {} \n".format(accessNumber))
- def accessExistingAccount(self):
- while True:
- name = input("Enter your name: ")
- accountNumber = input("Enter your account number: ")
- if accountNumber not in self.bankingAsystem.keys():
- print("Username or password incorrect\n")
- elif self.bankingAsystem[accountNumber][0] == name:
- while True:
- print("\n 1. Withdraw money\n \
- 2. Deposit money\n \
- 3. View your available balance\n \
- 4. Exit your account\n")
- userSecondChoise = int(input())
- if userSecondChoise == 1:
- while True:
- moneyWithdraw = float(input("you have {} $,How much money would you like to withdraw money: ".format(self.bankingAsystem[accountNumber][1])))
- if self.bankingAsystem[accountNumber][1] > moneyWithdraw:
- self.bankingAsystem[accountNumber][1] -= moneyWithdraw
- print("now you have {} $ in your account\n".format(self.bankingAsystem[accountNumber][1]))
- break
- else:
- print("you don't have enough money\n")
- elif userSecondChoise == 2:
- while True:
- depositMoney = float(input("How much money will you want to add to your account: "))
- if depositMoney >= 0:
- self.bankingAsystem[accountNumber][1] += depositMoney
- print("now you have {} $ in your account".format(self.bankingAsystem[accountNumber][1]))
- break
- else:
- print("Error! You tried to add {} $ to your account\n".format(depositMoney))
- elif userSecondChoise == 3:
- print("you have {} $ in your account\n".format(self.bankingAsystem[accountNumber][1]))
- elif userSecondChoise == 4:
- break
- bankingAsystem = BankingSystem()
- while True:
- print("\n 1. Create a new account\n \
- 2. Access an existing account\n \
- 3. Quit\n")
- userChoise = int(input())
- if userChoise == 1:
- bankingAsystem.createNewAccount()
- elif userChoise == 2:
- bankingAsystem.accessExistingAccount()
- elif userChoise == 3:
- quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement