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)
32 views
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 now
Download
Save Python Unit - 4-1 For Later
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)
32 views
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 now
Download
Save Python Unit - 4-1 For Later
Carousel Previous
Carousel Next
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
10-python-error-handling
PDF
No ratings yet
10-python-error-handling
35 pages
Python Notes
PDF
91% (11)
Python Notes
204 pages
Oops 3 Python DSA Notes 5
PDF
No ratings yet
Oops 3 Python DSA Notes 5
14 pages
DocScanner 9 Jul 2024 10-39 Am
PDF
No ratings yet
DocScanner 9 Jul 2024 10-39 Am
17 pages
Unit 6
PDF
No ratings yet
Unit 6
9 pages
Lecture_8#_comprehension_exceptions_2
PDF
No ratings yet
Lecture_8#_comprehension_exceptions_2
27 pages
Py New U5
PDF
No ratings yet
Py New U5
44 pages
unit 3 pp
PDF
No ratings yet
unit 3 pp
13 pages
Adobe Scan 10 Sep 2024
PDF
No ratings yet
Adobe Scan 10 Sep 2024
17 pages
What is an Exception
PDF
No ratings yet
What is an Exception
10 pages
Exception Handling
PDF
No ratings yet
Exception Handling
17 pages
Exception Handling
PDF
No ratings yet
Exception Handling
7 pages
Lecture-47 (Exception Handling)
PDF
No ratings yet
Lecture-47 (Exception Handling)
32 pages
CLASS 12 CS CHAPTER 1 2024-2025
PDF
No ratings yet
CLASS 12 CS CHAPTER 1 2024-2025
7 pages
unit 5 & 6(PWP)
PDF
No ratings yet
unit 5 & 6(PWP)
45 pages
UNIT-4 Exception -f File Handling
PDF
No ratings yet
UNIT-4 Exception -f File Handling
36 pages
Python Chap 6
PDF
No ratings yet
Python Chap 6
47 pages
Python Programming Unit-3
PDF
No ratings yet
Python Programming Unit-3
56 pages
Mark: 1-What Is The Class
PDF
No ratings yet
Mark: 1-What Is The Class
13 pages
CH 3 Exception Handling
PDF
No ratings yet
CH 3 Exception Handling
17 pages
8 Exception Handling
PDF
No ratings yet
8 Exception Handling
36 pages
CHAPTER_1___EXCEPTION_HANDLING_IN_PYTHON
PDF
No ratings yet
CHAPTER_1___EXCEPTION_HANDLING_IN_PYTHON
54 pages
Exception Handling in Python
PDF
No ratings yet
Exception Handling in Python
18 pages
TRY and EXCEPT
PDF
No ratings yet
TRY and EXCEPT
6 pages
Unit 2
PDF
No ratings yet
Unit 2
40 pages
Files and Exceptions
PDF
No ratings yet
Files and Exceptions
22 pages
07_20241021_ExceptionHandling_FileHandling
PDF
No ratings yet
07_20241021_ExceptionHandling_FileHandling
29 pages
Exception Handling
PDF
No ratings yet
Exception Handling
8 pages
python 5
PDF
No ratings yet
python 5
14 pages
Day 3.2 - CH8 - Handling Errors
PDF
No ratings yet
Day 3.2 - CH8 - Handling Errors
21 pages
Untitled Document (37)
PDF
No ratings yet
Untitled Document (37)
7 pages
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
ue228120
PDF
No ratings yet
ue228120
8 pages
1523_67_122_Module_4
PDF
No ratings yet
1523_67_122_Module_4
54 pages
Python Exception Handling PDF
PDF
100% (1)
Python Exception Handling PDF
23 pages
Exception Handling3
PDF
No ratings yet
Exception Handling3
13 pages
Exception Handling
PDF
No ratings yet
Exception Handling
6 pages
Python R20 - Unit-5
PDF
No ratings yet
Python R20 - Unit-5
36 pages
PYTHON unit 4 (1)
PDF
No ratings yet
PYTHON unit 4 (1)
9 pages
Exception Handling
PDF
No ratings yet
Exception Handling
38 pages
CMPUT 175 Lecture #5
PDF
No ratings yet
CMPUT 175 Lecture #5
43 pages
Exception Handling in Python Ingles
PDF
No ratings yet
Exception Handling in Python Ingles
3 pages
Module 5 File - Exception Handling
PDF
No ratings yet
Module 5 File - Exception Handling
2 pages
Exceptionhandlingpdf__2025_04_03_09_11_48
PDF
No ratings yet
Exceptionhandlingpdf__2025_04_03_09_11_48
21 pages
B13_TuHoc_09_Exception Handling
PDF
No ratings yet
B13_TuHoc_09_Exception Handling
13 pages
Exception Handling in Python
PDF
No ratings yet
Exception Handling in Python
3 pages
Exception_Handling_Notes
PDF
No ratings yet
Exception_Handling_Notes
3 pages
Datetime Filehandling Exception
PDF
No ratings yet
Datetime Filehandling Exception
14 pages
8. Exceptions
PDF
No ratings yet
8. Exceptions
42 pages
Unit 5-1
PDF
No ratings yet
Unit 5-1
14 pages
Exception Handling (CS)
PDF
No ratings yet
Exception Handling (CS)
23 pages
rakesh assignment 3
PDF
No ratings yet
rakesh assignment 3
19 pages
Basic Exception Handling
PDF
No ratings yet
Basic Exception Handling
7 pages
Python Programming - Unit-5
PDF
No ratings yet
Python Programming - Unit-5
33 pages
unit-412
PDF
No ratings yet
unit-412
50 pages
Python Exception Handling
PDF
No ratings yet
Python Exception Handling
10 pages
Lab 3-AI
PDF
No ratings yet
Lab 3-AI
9 pages