Python Assignment 02
Python Assignment 02
Date
doq: Doqt)
dogSourd()
Cot Cat )
Cat Sourd
Fege Ne 3
roq ram
class Necgatív eAmount Error (E xception):
pass
class Bonk Accouht
def-initc sel E, balance oJ:
Self bolance balan ce
det deposii (setf, amourtJ:
Yoi se Negot l'e Amount Enor (^ (onnot depocit
aneqatie Qmount M
self balance + amount
del cuithdraw (sel, amountJ:
Rrogtam
clas lanent
det --inite (sel f,ngme)
Seiname nome
det Shoc name gel:
print ( " Name: setfname?")
cla ss ehtpchild Panent)
def -init (setf naMe, aqe)
Supe). -- in it hame )
sele-age aqe
Shos- defcuileCsetIfJ:
Sup n() Shoos nameU
class engine
de Start- engine Cself) e
prini(engine Standteal "')
class Body i
def build -bodyCset f) :
priotCbodybu'lt:h)
class canl engine Gody) i
def cen assemble (Self) :
Sel Stt enqine()
Self. buid'- body t
Pragrami
def devide-andaccess Ait4 Istnde tydiuto)
try
esult = Ast Cinden1/diyisor
prin( p"Result esulf ")
eKCept lndexlxoy !
print (" nder out of range "
eKcep 2exo0iysion Eror
pint( Canno) diyide by 2exo |")
erCepi execpton al e
#usage
narabens a Cio,20,30]
tvide -cndaaress Cnumben, S,2)
divide- anda access (numbens, , a