Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

class BankSystem: def _ _ init _ _ ( self ) : self.balance = 0 self.is _ logged _ in = False def login (

class BankSystem:
def __init__(self):
self.balance =0
self.is_logged_in = False
def login(self, password):
if password =='1234':
self.is_logged_in = True
print("Login successful.")
else:
print("Incorrect password.")
def logout(self):
self.is_logged_in = False
print("Logged out.")
def deposit(self, amount):
if self.is_logged_in:
self.balance += amount
print(f"Deposited \$ {amount}. New balance is \$ {self.balance}.")
else:
print("Please login first.")
def withdraw(self, amount):
if self.is_logged_in:
if amount <= self.balance:
self.balance -= amount
print(f"Withdrew \$ {amount}. New balance is \$ {self.balance}.")
else:
print("Insufficient balance.")
else:
print("Please login first.")
bank = BankSystem()
bank.login('1234')
bank.deposit(1000)
bank.withdraw(500)
bank.logout() draw graph for that code

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions