SlidePub
Home
Categories
Login
Register
Home
General
Chapter 11-Operator overloading in python.pptx
Chapter 11-Operator overloading in python.pptx
soumyamohapatra46
1 views
10 slides
Oct 11, 2025
Slide
1
of 10
Previous
Next
1
2
3
4
5
6
7
8
9
10
About This Presentation
operator overloading
Size:
422.1 KB
Language:
en
Added:
Oct 11, 2025
Slides:
10 pages
Slide Content
Slide 1
Python Programming Using Problem Solving Approach Reema Thareja 1 © Oxford University Press 2017. All rights reserved. 1
Slide 2
2 CHAPTER 11 Operator Overloading © Oxford University Press 2017. All rights reserved.
Slide 3
Introduction 3 Python allows programmers to redefine the meaning of operators when they operate on class objects. This feature is called operator overloading . Operator overloading allows programmers to extend the meaning of existing operators so that in addition to the basic data types, they can be also applied to user defined data types. Another form of Polymorphism Like function overloading, operator overloading is also a form of compile-time polymorphism. Operator overloading, is therefore less commonly known as operator ad hoc polymorphism since different operators have different implementations depending on their arguments. Operator overloading is generally defined by the language, the programmer, or both. © Oxford University Press 2017. All rights reserved.
Slide 4
Implementing Operator Overloading — Example 4 © Oxford University Press 2017. All rights reserved.
Slide 5
Operators and Their Corresponding Function Names 5 © Oxford University Press 2017. All rights reserved.
Slide 6
Reverse Adding 6 In operator overloading functions, we can add a basic data type on a user defined object by writing user_defined_object + basic_data_type_var but cannot do the reverse. However, to provide greater flexibility, we should also be able to perform the operation in reverse order, that is, adding a non-class object to the class object. For this, Python provides the concept of reverse adding. For reverse adding, just overload the __ radd __() fnction © Oxford University Press 2017. All rights reserved.
Slide 7
Overriding __ getitem __() and __ setitem __() — Example 7 © Oxford University Press 2017. All rights reserved.
Slide 8
Overriding t he i n Operator 8 in is a membership operator that checks whether the specified item is in the variable of built-in type or not We can overload the same operator to check whether the given value is a member of a class variable or not. To overload the in operator we have to use the function __contains__(). © Oxford University Press 2017. All rights reserved. Example:
Slide 9
Overloading Miscellaneous Functions — Example 9 © Oxford University Press 2017. All rights reserved.
Slide 10
Overriding the __c all __() Method 10 The __call __() method is used to overload call expressions. The __call__ method is called automatically when an instance of the class is called. It can be passed any positional or keyword arguments. Like other functions, __call __() also supports all of the argument-passing modes. © Oxford University Press 2017. All rights reserved. Example:
Tags
Categories
General
Download
Download Slideshow
Get the original presentation file
Quick Actions
Embed
Share
Save
Print
Full
Report
Statistics
Views
1
Slides
10
Age
52 days
Related Slideshows
22
Pray For The Peace Of Jerusalem and You Will Prosper
RodolfoMoralesMarcuc
32 views
26
Don_t_Waste_Your_Life_God.....powerpoint
chalobrido8
33 views
31
VILLASUR_FACTORS_TO_CONSIDER_IN_PLATING_SALAD_10-13.pdf
JaiJai148317
31 views
14
Fertility awareness methods for women in the society
Isaiah47
30 views
35
Chapter 5 Arithmetic Functions Computer Organisation and Architecture
RitikSharma297999
27 views
5
syakira bhasa inggris (1) (1).pptx.......
ourcommunity56
29 views
View More in This Category
Embed Slideshow
Dimensions
Width (px)
Height (px)
Start Page
Which slide to start from (1-10)
Options
Auto-play slides
Show controls
Embed Code
Copy Code
Share Slideshow
Share on Social Media
Share on Facebook
Share on Twitter
Share on LinkedIn
Share via Email
Or copy link
Copy
Report Content
Reason for reporting
*
Select a reason...
Inappropriate content
Copyright violation
Spam or misleading
Offensive or hateful
Privacy violation
Other
Slide number
Leave blank if it applies to the entire slideshow
Additional details
*
Help us understand the problem better