Overview Python is fully object-oriented: you can define your own classes, inher
ID: 3735279 • Letter: O
Question
Overview
Python is fully object-oriented: you can define your own classes, inherit from your own or built-in classes, and instantiate the classes you've defined.
Defining a class in Python is simple. Just define the class and start coding. A Python class starts with the reserved word class, followed by the class name.
Instructions
Original Post: Classes are everyday life objects. Think of an object that you use in everyday life, possibly a bank account, ATM machine. Write a simple class and the data attributes. Once you have written the class, write a program that creates objects in relation to the class and stores data in them. You can add as many as you would like.
Remember to paste the code directly into your post!
Explanation / Answer
Here the simple python code with all the requirements that you stated above
print('Welcome to the Bank ATM')
restart=('Y')
tries = 3
bal = 67.14
while tries >= 0:
pin = int(input('Please Enter You 4 Digit Pin: '))
if pin == (1234):
print('You entered you pin Correctly ')
while restart not in ('n','NO','no','N'):
print('Please Press 1 For Your Balance ')
print('Please Press 2 To Make a Withdrawl ')
print('Please Press 3 To Pay in ')
print('Please Press 4 To Return Card ')
option = int(input('What Would you like to choose?'))
if option == 1:
print('Your Balance is £',bal,' ')
restart = input('Would You you like to go back? ')
if restart in ('n','NO','no','N'):
print('Thank You')
break
elif option == 2:
option2 = ('y')
withdrawl = float(input('How Much Would you like to
withdraw? £10/£20/£40/£60/£80/£100 for other enter 1: '))
if withdrawl in [10, 20, 40, 60, 80, 100]:
bal = bal - withdrawl
print (' Your Balance is now £',bal)
restart = input('Would You you like to go back? ')
if restart in ('n','NO','no','N'):
print('Thank You')
break
elif withdrawl != [10, 20, 40, 60, 80, 100]:
print('Invalid Amount, Please Re-try ')
restart = ('y')
elif withdrawl == 1:
withdrawl = float(input('Please Enter Desired amount:'))
elif option == 3:
Pay_in = float(input('How Much Would You Like To Pay In? '))
bal = bal + Pay_in
print (' Your Balance is now £',bal)
restart = input('Would You you like to go back? ')
if restart in ('n','NO','no','N'):
print('Thank You')
break
elif option == 4:
print('Please wait whilst your card is Returned... ')
print('Thank you for you service')
break
else:
print('Please Enter a correct number. ')
restart = ('y')
elif pin != ('1234'):
print('Incorrect Password')
tries = tries - 1
if tries == 0:
print(' No more tries')
break
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.