Python Lecture 14-Object Oriented Programming
Python Lecture 14-Object Oriented Programming
Programming - 1
Objects
• Python supports different type of data
– 125 (int), 24.04 (float), “Hello” (string)
– [3,7,8,10] (list)
– {“India”:”New Delhi”, “Japan”:”Tokyo”}
• Each of above is an object
• Every object has a type, internal data
representation and procedures for
interaction.
• An object is an instance
– 125 is an instance of int, Hello is an instance of
string
Objects
• In Pyhton everything is an object
• Can create an object
• Can manipulate objects
• Can destroy objects
explicitly using del or just “forget” about them python
system will reclaim destroyed or inaccessible objects
–called “garbage collection”
Objects
Equivalent
Classes: Methods
c=Coordinate(3,4)
print(c) à <3,4>
Example: Fraction
Example: Fraction