Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
41 views
14 pages
Python Unit - 4-1
Python programming
Uploaded by
abdul7ahad73
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save Python Unit - 4-1 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
41 views
14 pages
Python Unit - 4-1
Python programming
Uploaded by
abdul7ahad73
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save Python Unit - 4-1 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 14
Search
Fullscreen
Promon onit-y Overs Rr oO 4. How method overriding works in python? Explain with an example progran: Q discuss the implementation a€ yperaly overloading en python wortee a progon that overloads the + operaar © Hat (oe add two objects of Clals proton. ey consider @ Kectangle class and create Tid progyan f& Rectongle objects. Lirite p¥thon check tohether the Area’ of the forse gectange res) gieattr than second by ovetloading > Operabr. 4 Hote about exteption handling an example using try, else and finaly iz ce and handle use’ defined . Enplain wih & How to create yall — enteptions 1m python. g Writ a python prograa to plement multiple Encept blocks and finally Block).tow wniethed nerrtding wor br tr Potton) Chplain with aty example pregrant, ) hatred pveNvi dung ae "FE dapunee Suecame te provide aspecific tnpltmentaten bo murmed already depiniel ty Hay tuperciam, * Matised bvewling i pardeutar ty Libel LA SCEMOM OS Ucheml o fubclam needs be Lanance Sy modify thy fon ctienatity Uinhe vited Fromils tubeians white masntoairg the ovat SHCA am of interface Example | Class Shape : ; Curput Aep mura (carp) Ie pa preaty Clans Sqyacird Cchape): Sena ia ae GR oie (set sata): Self aide « Side: 1 ath once tse4 >i . vel Geig Side * corp cide A Drives Code : > squat Cro) a. j print [Ares of 4a in, Smeal 7]ui, tee re pie rie Meat ton ooo make Fu heel Goeth eo" Th han ala hives Ahtaed a ies dracticrs. pe Ogee BGuevatey Overleading PAithm,we can change dye woo Opevaten’s tiov\e Pee kel tate ciarvyle, the + cperoden with pertovery achnedtc of or Jur ruanberSy mag? two \tele, 0 are wD Bling ‘ amare ‘ny fh fallout the carne pe retor p ‘dtlicse mening + Bat -
add (fay which teva % Fats = t.d=- (A, £2) eae : >, dodet the addPion cp “ oil oud the way we eperttter yee aly wh: nee, olhes ana asics hi «Be eS a eR EN ie ECR age TRS Tpke ae oy ee | Z _Consrder a Rectangle. Class and Create. Two Rectangles Objects. Liytte fey thov) program to check bihether the Arca of the First Rectang le tt Greater. than Second by overloading > Operator. : ‘ A ee Class Rectangle : . def init (ergy) : Cue. £= SELF. 626 af arcatserpe): ‘geturn cele. 4 * Seip. b def __ gt_— (tf, other): Yeturn celP.areal) > Other. areal) £12 cat (input-( enter Aergth 1 sup hows b1 2 lat (input enter breadtha:")) ~ 71 > Rectangle (1,41) Ld cat (input Center Length 2: y be me(inputC Enter breadth 20) > oFoutput: fntcr length 4 2 Grtcr Areadth1 > 3 Giter Lereg th D5 Oittr breadth Q: Ss R2 har greaterY binite about exception handling. Explain wry, an example ustng try. ele and finally 9 A: Exception handling: wat MAN exception (Ss an event, Which Occurt during the execution of a program, that disyupts the viormal flow of the program's Grisiuctons. : * An exception ws a python obfect that wpresents AN error. # When a pythora eript raives an exc Pplin, & must ether handle the exception | emmediattly otherwise Ct would terminate . and come out. x Pts importorit te handle exception propely én your code using try- CKxCpl blocks or other error- handling technig ues, in ordey | gracefully handle errors and prevent the program fiom Crashing. ; a* Syntanes (or Cxceptions 1 try... except ty : # Cok that may cause exception except: . 4 Code t run Wher exception OCCUrs lea Multiple except blocks ty H Code that moy couse euceplon Crcept Exceptiorrt: Gxception 1 haridiing Code Except Excephiona: Gucption 2 handlyig Lode 2 ty , encept, efse oa # code that : May cause er Cop tionH Code that NAY Cate excep tion pe: Hop oral block 4 tendling of exceptron | Cnetue VE 0 exception Uy : / Lome code. .. (Always executed )Cxample: #- try, else and finally try hus 50 ) de ? int (input (enter the denaminagtor: ’ yese (V4 /ae) ' : priat( RIGTSVOK) EES ote o y | Chept ‘ZeroDivistor Grrr : ‘) iol peat c oo) Oi a@ ZERO ry not allo Bak:Z . else = ae print( The reruwt of distor) Oper (nally : punt (End of pregram oeoutput’ Entcr the ce norminato , Yee . performed Successful e yesult of diviston otal 3 Gad of program. aWiese toc keyword ie © dumdo-nevt. ryder, 4het cllows you ae dri Tris can Lb | fon te 99er On ercenl © dime wth berth but deferred @xteph os uw" £3ce Pe, Se cd Yee hWe cen detre cunty., Excel. fey Meeting a wes Sess thet ic derived tio, , | se Magi -in" Ceeerhom* clase Synton Sipe Ba Clone Cvestunlrs or CExte etn) é Pes. Evay! exter, See toen Crpov - Hex? , Custcicewer fe VSerceLaed ayy wabyich imhevs fon the Excepdion clace &} hoes Age_ Excembon(Cxce Phen): Pia= Oge = ind CABLE. terAge:*)) Ca CGS < it: Yor N94 Excepos else: Punt (te kg tole sy Vete*) SMEPE Age ccoption. Prt (“Under oge . CON Uebe 444 Mattipte exec ept and Ficaty8 lock. Prxixct (‘Handtin TOU =SO de — toe-(. CES a Ges Per PRE Hn te ape denoroinaton') A] ote) Division Perforred Success Fully 1) CxCept 2€70 Division Error: Prist¢ Denornindtor aS Zes0 js TOE allacsedl!! ae Cept Vorlere Evrors ie EComty “Tntegers Should be Entered") cles Print C* The wesult of divi oaitty ’ S02 Operation is 373) cD" Cee Esa ar Progx.
You might also like
Class 12 Ncert Solution Computer Science Chap 1 2024-25
PDF
No ratings yet
Class 12 Ncert Solution Computer Science Chap 1 2024-25
20 pages
8 Exception Handling
PDF
No ratings yet
8 Exception Handling
36 pages
Lecture 8# Comprehension Exceptions 2
PDF
No ratings yet
Lecture 8# Comprehension Exceptions 2
27 pages
07 20241021 ExceptionHandling FileHandling
PDF
No ratings yet
07 20241021 ExceptionHandling FileHandling
29 pages
Python R20 - Unit-5
PDF
No ratings yet
Python R20 - Unit-5
36 pages
Python Sem 6 Notes
PDF
No ratings yet
Python Sem 6 Notes
19 pages
Day 3.2 - CH8 - Handling Errors
PDF
No ratings yet
Day 3.2 - CH8 - Handling Errors
21 pages
Unit 3 PP
PDF
No ratings yet
Unit 3 PP
13 pages
Files and Exceptions
PDF
No ratings yet
Files and Exceptions
22 pages
Class 12 Notes Computer Science Chap 1 (2024-25)
PDF
No ratings yet
Class 12 Notes Computer Science Chap 1 (2024-25)
4 pages
Chapter 1 Exception Handling in Python
PDF
No ratings yet
Chapter 1 Exception Handling in Python
54 pages
Datetime Filehandling Exception
PDF
No ratings yet
Datetime Filehandling Exception
14 pages
PYTHON Unit 4
PDF
No ratings yet
PYTHON Unit 4
9 pages
Exception Handling
PDF
No ratings yet
Exception Handling
8 pages
Unit 6
PDF
No ratings yet
Unit 6
9 pages
Exception Handling Notes
PDF
No ratings yet
Exception Handling Notes
3 pages
Python Chap 6
PDF
No ratings yet
Python Chap 6
47 pages
Exceptionhandlingpdf 2025 04 03 09 11 48
PDF
No ratings yet
Exceptionhandlingpdf 2025 04 03 09 11 48
21 pages
1523 67 122 Module 4
PDF
No ratings yet
1523 67 122 Module 4
54 pages
CMPUT 175 Lecture #5
PDF
No ratings yet
CMPUT 175 Lecture #5
43 pages
Unit 2
PDF
No ratings yet
Unit 2
40 pages
B13 - TuHoc - 09 - Exception Handling
PDF
No ratings yet
B13 - TuHoc - 09 - Exception Handling
13 pages
Unit 5-1
PDF
No ratings yet
Unit 5-1
14 pages
Oops 3 Python DSA Notes 5
PDF
No ratings yet
Oops 3 Python DSA Notes 5
14 pages
Exception Handling in Python
PDF
No ratings yet
Exception Handling in Python
18 pages
DocScanner 9 Jul 2024 10-39 Am
PDF
No ratings yet
DocScanner 9 Jul 2024 10-39 Am
17 pages
Ue 228120
PDF
No ratings yet
Ue 228120
8 pages
Exception Handling
PDF
No ratings yet
Exception Handling
38 pages
UNIT-4 Exception - F File Handling
PDF
No ratings yet
UNIT-4 Exception - F File Handling
36 pages
Untitled Document
PDF
No ratings yet
Untitled Document
7 pages
TRY and EXCEPT
PDF
No ratings yet
TRY and EXCEPT
6 pages
Exception Handling
PDF
No ratings yet
Exception Handling
7 pages
Exception Handling
PDF
No ratings yet
Exception Handling
17 pages
Exceptions
PDF
No ratings yet
Exceptions
42 pages
Lecture-47 (Exception Handling)
PDF
No ratings yet
Lecture-47 (Exception Handling)
32 pages
Exception Handling
PDF
No ratings yet
Exception Handling
8 pages
Exception Handling in Python
PDF
No ratings yet
Exception Handling in Python
3 pages
Unit 5 & 6 (PWP)
PDF
No ratings yet
Unit 5 & 6 (PWP)
45 pages
Exception Handling
PDF
No ratings yet
Exception Handling
6 pages
Exception Handeling in Python
PDF
No ratings yet
Exception Handeling in Python
21 pages
Mark: 1-What Is The Class
PDF
No ratings yet
Mark: 1-What Is The Class
13 pages
What Is An Exception
PDF
No ratings yet
What Is An Exception
10 pages
Exception Handling in Python Ingles
PDF
No ratings yet
Exception Handling in Python Ingles
3 pages
Python Notes
PDF
91% (11)
Python Notes
204 pages
Python 5
PDF
No ratings yet
Python 5
14 pages
Exception Handling (CS)
PDF
No ratings yet
Exception Handling (CS)
23 pages
Class 12 CS Chapter 1 2024-2025
PDF
No ratings yet
Class 12 CS Chapter 1 2024-2025
7 pages
CH 3 Exception Handling
PDF
No ratings yet
CH 3 Exception Handling
17 pages
PP I3 Expt5 RN41
PDF
No ratings yet
PP I3 Expt5 RN41
19 pages
Exception Handling3
PDF
No ratings yet
Exception Handling3
13 pages
Java 02
PDF
No ratings yet
Java 02
14 pages
Python Programming Unit-3
PDF
No ratings yet
Python Programming Unit-3
56 pages
Module 5 File - Exception Handling
PDF
No ratings yet
Module 5 File - Exception Handling
2 pages
Py New U5
PDF
No ratings yet
Py New U5
44 pages
Python Exception Handling PDF
PDF
100% (1)
Python Exception Handling PDF
23 pages
Adobe Scan 10 Sep 2024
PDF
No ratings yet
Adobe Scan 10 Sep 2024
17 pages
Exception Handling
PDF
No ratings yet
Exception Handling
13 pages