Professional Documents
Culture Documents
OBJECTS
BY MAHI MUDGAL
WHAT WE GET IN THIS
In Python everything is an object, and got to use id and is to deepen our understanding of what's happening under
the hood when using Python to create and modify objects.
We also learned the difference between mutable objects, that can be modified after creation,
and immutable objects, which cannot.
We saw that
Understanding how Python "sees" objects is a key to becoming a better Python programmer. I hope this ppt will
help you on your journey to mastering Python.
DIFFERENCE BETWEEN MUTABLE AND
IMMUTABLE OBJECTS
. The property of whether or not data objects can be modified in the same memory
location where they are stored is called mutability
MUTABLE IMMUTABLE
• Mutable objects are those object whose • Immutable objects are those objects
value or content can be changed as and whose value or content can not be
when required. changed .
• FOR EXAMPLE:-list,dictionaries • FOR EXAMPLE:-Tuple,String,Numeric
DATA TYPE IN PHYTHON
SET
Numeric:- Any representation of data which has numeric value. Python identifies three types of numbers –
integer, float and complex number.
String A collection of one or more characters put in single, double or triple quotes.
1-STRING:- Examples: ‘Hello’, "Hello", "'Hello'", """Hello"""
CODE CODE
Tuple- An ordered collection of one or more data items, not
Object 2 :- Tuple
necessarily of same type put in parentheses. The contents of a
tuple cannot be modified – it is immutable - after the tuple is
created. Examples: (1,"Ravi", 75.50, True)
1)
6) reverse()
Reverses the order of items in a list.
Rearranges items in the list according to alphabetical order. Default is ascending order. For descending
7) SORT:- order put reverse=True as argument in function bracket.
ASCENDING ORDER
DSCENDING ORDER
WE CAN CONVERT ONE SEQUENCE OBJECT TO ANOTHER
The Following utility functions help in converting one sequence data type to other
EXAMPLE:-3
Code
Tuple ,list and string can be converted in set by using set function
Dictionary are unordered collection of object because it dosent remember the place of object in it
For example
INPUT OUTPUT