SlideShare a Scribd company logo
1 of 10
PythonTutorials
Lecture -2-
By: Ali Sattar
To: Everyone
Contents:
1.What is the data type?
2.The data types in python.
3. MutableVs. Immutable objects?
Data type it is just determine the type of the object in your program. Python will
store that object with it’s type in the memory, also the interpreter needs to check the
status of that object for the operation later. The general from to define any variable of any
data type in python is look like below:
Variable Name = Object
A = 20
So, here A is the variable name and 20 is the object content which is assigned to the
variable, you see now how python deal with the data types.
1.What is the data type?
2.The data types in python
The data types in python can be classified into five categories or classes:
2.1 Boolean.
2.2 Numeric types.
2.3 Sequences.
2.4 Sets.
2.5 Mapping.
2.The data types in python
2.1 Boolean: This type has a two values either: True or False. This type can be used with
decision making statements or where we want to represent the two values.
Ex: T =True
2.2 Numeric types: This category can be classified into four data types: int, float, long
and complex.
Ex: A = 20 ; F = 2.5 ; L = 21321L ; C = 10 + 5j
► For long type now is not working in python 3.x but it was working in python 2.x and we
need to put L in the last. For complex type is just consist of a two parts: Real part and
imaginary part
2.3 Sequences: This category can be classified into four data types: String, bytes, byte array, list
and tuple.
Ex:
S = “Ali Sattar” or S = str(“Hello”)  S is a string type
B1 = b1’A’  b1 is a bytes type, it is like char type in other languages.
B2 = b2’Python’  b2 is another bytes type, but it followed by sequence of letters.
BA = (“Python, Java”, “utf8”)  b is of type bytearray returns a two items only.
L = [‘String’, 24, 2.5, ‘b’]  L is of type list contains multiple items.
T = (‘One’, ‘Two’, ‘Three’)  T is of type tuple, it is similar to list but there is a difference.
2. The data types in python
2.The data type in python
► For bytes data type is look like the char data type but here is expanded with not only
one byte but with a sequence of bytes like you did noticed before in the examples.
► For list it is just a sequences of items started by 0m where list object can contains many
data types for other objects ok. “List is changeable; means can be modified by insert,
update and even delete”.
► For tuple is similar to list but surround it’s items with () instead of []. “Tuple is not
changeable, so you cannot do update, insert and even delete”.
► You can use the method str() to convert any other data type to string type.
► We can use bytearray too if we want to represent a sequence of letters as list.
2.4 Sets: A set is unordered collection of items inside curly braces {}. The object inside
the list is non-changeable but the set can be modified by adding or removing an items.
The set can contain items of different data types, each item inside the set is separated
comma (,) and built in using the method set(). The difference between set and list is
list items can be updated in place while set items are not.
Ex: my_Set = { 100, b’B’, “Ali Sattar”, 20.5, (1, 2, 3) }
► Here as you can see, we created a set of different items and with a different data
types.
2. The data type in python
2.The data type in python
2.5 Mapping: Dictionary is the only data type here, the dictionary is unordered collection
of items (elements) where the items are surrounded by a curly braces too {} like set. Each
item is separated by comma and it has a key: value pair. Dictionary items are changeable
like list and bytearray.
Ex:
Diction1 = { 1: ‘Sunday’, 2: ‘Monday’, 3: ‘Tuesday’ }
Diction2 = { ‘A’: ‘Apple’, ‘B’: ‘Bannana’, ‘C’: ‘Chocolate’ }
Diction3 = { 12: ‘3*4’, 15: ‘3*5’}
3. Mutable vs. Immutable objects
Mutable Object: It is the object in which it’s value can be changed. For example: list,
bytearray, byte and dictionary.
Immutable Object: It is the object in which it’s value cannot be changed. For example:
int, float, str, tuple and set.

More Related Content

What's hot (20)

Basic data types in python
Basic data types in pythonBasic data types in python
Basic data types in python
 
Python Data-Types
Python Data-TypesPython Data-Types
Python Data-Types
 
Values and Data types in python
Values and Data types in pythonValues and Data types in python
Values and Data types in python
 
Lesson 03 python statement, indentation and comments
Lesson 03   python statement, indentation and commentsLesson 03   python statement, indentation and comments
Lesson 03 python statement, indentation and comments
 
Python dictionary
Python dictionaryPython dictionary
Python dictionary
 
Python - object oriented
Python - object orientedPython - object oriented
Python - object oriented
 
Python Modules
Python ModulesPython Modules
Python Modules
 
Python list
Python listPython list
Python list
 
Python list
Python listPython list
Python list
 
Python recursion
Python recursionPython recursion
Python recursion
 
Python programming : Strings
Python programming : StringsPython programming : Strings
Python programming : Strings
 
Array in c programming
Array in c programmingArray in c programming
Array in c programming
 
Class, object and inheritance in python
Class, object and inheritance in pythonClass, object and inheritance in python
Class, object and inheritance in python
 
Python : Data Types
Python : Data TypesPython : Data Types
Python : Data Types
 
Pointers in C/C++ Programming
Pointers in C/C++ ProgrammingPointers in C/C++ Programming
Pointers in C/C++ Programming
 
8 python data structure-1
8 python data structure-18 python data structure-1
8 python data structure-1
 
Chapter 14 strings
Chapter 14 stringsChapter 14 strings
Chapter 14 strings
 
Chapter 07 inheritance
Chapter 07 inheritanceChapter 07 inheritance
Chapter 07 inheritance
 
Python-List.pptx
Python-List.pptxPython-List.pptx
Python-List.pptx
 
Lesson 02 python keywords and identifiers
Lesson 02   python keywords and identifiersLesson 02   python keywords and identifiers
Lesson 02 python keywords and identifiers
 

Similar to Data types in python lecture (2)

13- Data and Its Types presentation kafss
13- Data and Its Types presentation kafss13- Data and Its Types presentation kafss
13- Data and Its Types presentation kafssAliKhokhar33
 
Python data type
Python data typePython data type
Python data typenuripatidar
 
Anton Kasyanov, Introduction to Python, Lecture4
Anton Kasyanov, Introduction to Python, Lecture4Anton Kasyanov, Introduction to Python, Lecture4
Anton Kasyanov, Introduction to Python, Lecture4Anton Kasyanov
 
Python data type
Python data typePython data type
Python data typeJaya Kumari
 
11 Introduction to lists.pptx
11 Introduction to lists.pptx11 Introduction to lists.pptx
11 Introduction to lists.pptxssuser8e50d8
 
Presentation on python data type
Presentation on python data typePresentation on python data type
Presentation on python data typeswati kushwaha
 
COMPUTER SCIENCE SUPPORT MATERIAL CLASS 12.pdf
COMPUTER SCIENCE SUPPORT MATERIAL CLASS 12.pdfCOMPUTER SCIENCE SUPPORT MATERIAL CLASS 12.pdf
COMPUTER SCIENCE SUPPORT MATERIAL CLASS 12.pdfrajkumar2792005
 
The Datatypes Concept in Core Python.pptx
The Datatypes Concept in Core Python.pptxThe Datatypes Concept in Core Python.pptx
The Datatypes Concept in Core Python.pptxKavitha713564
 
PYTHON LISTsjnjsnljnsjnosojnosojnsojnsjsn.pptx
PYTHON LISTsjnjsnljnsjnosojnosojnsojnsjsn.pptxPYTHON LISTsjnjsnljnsjnosojnosojnsojnsjsn.pptx
PYTHON LISTsjnjsnljnsjnosojnosojnsojnsjsn.pptxsurajnath20
 
MODULE-2.pptx
MODULE-2.pptxMODULE-2.pptx
MODULE-2.pptxASRPANDEY
 
Python Data Types.pdf
Python Data Types.pdfPython Data Types.pdf
Python Data Types.pdfNehaSpillai1
 
Python Data Types (1).pdf
Python Data Types (1).pdfPython Data Types (1).pdf
Python Data Types (1).pdfNehaSpillai1
 
Data Types - Premetive and Non Premetive
Data Types - Premetive and Non Premetive Data Types - Premetive and Non Premetive
Data Types - Premetive and Non Premetive Raj Naik
 
RANDOMISATION-NUMERICAL METHODS FOR ENGINEERING.pptx
RANDOMISATION-NUMERICAL METHODS  FOR ENGINEERING.pptxRANDOMISATION-NUMERICAL METHODS  FOR ENGINEERING.pptx
RANDOMISATION-NUMERICAL METHODS FOR ENGINEERING.pptxOut Cast
 

Similar to Data types in python lecture (2) (20)

13- Data and Its Types presentation kafss
13- Data and Its Types presentation kafss13- Data and Its Types presentation kafss
13- Data and Its Types presentation kafss
 
Chapter - 2.pptx
Chapter - 2.pptxChapter - 2.pptx
Chapter - 2.pptx
 
Python data type
Python data typePython data type
Python data type
 
Anton Kasyanov, Introduction to Python, Lecture4
Anton Kasyanov, Introduction to Python, Lecture4Anton Kasyanov, Introduction to Python, Lecture4
Anton Kasyanov, Introduction to Python, Lecture4
 
set.pptx
set.pptxset.pptx
set.pptx
 
Python data type
Python data typePython data type
Python data type
 
11 Introduction to lists.pptx
11 Introduction to lists.pptx11 Introduction to lists.pptx
11 Introduction to lists.pptx
 
Presentation on python data type
Presentation on python data typePresentation on python data type
Presentation on python data type
 
COMPUTER SCIENCE SUPPORT MATERIAL CLASS 12.pdf
COMPUTER SCIENCE SUPPORT MATERIAL CLASS 12.pdfCOMPUTER SCIENCE SUPPORT MATERIAL CLASS 12.pdf
COMPUTER SCIENCE SUPPORT MATERIAL CLASS 12.pdf
 
The Datatypes Concept in Core Python.pptx
The Datatypes Concept in Core Python.pptxThe Datatypes Concept in Core Python.pptx
The Datatypes Concept in Core Python.pptx
 
pythondatatypes.pptx
pythondatatypes.pptxpythondatatypes.pptx
pythondatatypes.pptx
 
PYTHON LISTsjnjsnljnsjnosojnosojnsojnsjsn.pptx
PYTHON LISTsjnjsnljnsjnosojnosojnsojnsjsn.pptxPYTHON LISTsjnjsnljnsjnosojnosojnsojnsjsn.pptx
PYTHON LISTsjnjsnljnsjnosojnosojnsojnsjsn.pptx
 
Python for beginners
Python for beginnersPython for beginners
Python for beginners
 
unit 1.docx
unit 1.docxunit 1.docx
unit 1.docx
 
AI_2nd Lab.pptx
AI_2nd Lab.pptxAI_2nd Lab.pptx
AI_2nd Lab.pptx
 
MODULE-2.pptx
MODULE-2.pptxMODULE-2.pptx
MODULE-2.pptx
 
Python Data Types.pdf
Python Data Types.pdfPython Data Types.pdf
Python Data Types.pdf
 
Python Data Types (1).pdf
Python Data Types (1).pdfPython Data Types (1).pdf
Python Data Types (1).pdf
 
Data Types - Premetive and Non Premetive
Data Types - Premetive and Non Premetive Data Types - Premetive and Non Premetive
Data Types - Premetive and Non Premetive
 
RANDOMISATION-NUMERICAL METHODS FOR ENGINEERING.pptx
RANDOMISATION-NUMERICAL METHODS  FOR ENGINEERING.pptxRANDOMISATION-NUMERICAL METHODS  FOR ENGINEERING.pptx
RANDOMISATION-NUMERICAL METHODS FOR ENGINEERING.pptx
 

Recently uploaded

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 

Recently uploaded (20)

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 

Data types in python lecture (2)

  • 2. Contents: 1.What is the data type? 2.The data types in python. 3. MutableVs. Immutable objects?
  • 3. Data type it is just determine the type of the object in your program. Python will store that object with it’s type in the memory, also the interpreter needs to check the status of that object for the operation later. The general from to define any variable of any data type in python is look like below: Variable Name = Object A = 20 So, here A is the variable name and 20 is the object content which is assigned to the variable, you see now how python deal with the data types. 1.What is the data type?
  • 4. 2.The data types in python The data types in python can be classified into five categories or classes: 2.1 Boolean. 2.2 Numeric types. 2.3 Sequences. 2.4 Sets. 2.5 Mapping.
  • 5. 2.The data types in python 2.1 Boolean: This type has a two values either: True or False. This type can be used with decision making statements or where we want to represent the two values. Ex: T =True 2.2 Numeric types: This category can be classified into four data types: int, float, long and complex. Ex: A = 20 ; F = 2.5 ; L = 21321L ; C = 10 + 5j ► For long type now is not working in python 3.x but it was working in python 2.x and we need to put L in the last. For complex type is just consist of a two parts: Real part and imaginary part
  • 6. 2.3 Sequences: This category can be classified into four data types: String, bytes, byte array, list and tuple. Ex: S = “Ali Sattar” or S = str(“Hello”)  S is a string type B1 = b1’A’  b1 is a bytes type, it is like char type in other languages. B2 = b2’Python’  b2 is another bytes type, but it followed by sequence of letters. BA = (“Python, Java”, “utf8”)  b is of type bytearray returns a two items only. L = [‘String’, 24, 2.5, ‘b’]  L is of type list contains multiple items. T = (‘One’, ‘Two’, ‘Three’)  T is of type tuple, it is similar to list but there is a difference. 2. The data types in python
  • 7. 2.The data type in python ► For bytes data type is look like the char data type but here is expanded with not only one byte but with a sequence of bytes like you did noticed before in the examples. ► For list it is just a sequences of items started by 0m where list object can contains many data types for other objects ok. “List is changeable; means can be modified by insert, update and even delete”. ► For tuple is similar to list but surround it’s items with () instead of []. “Tuple is not changeable, so you cannot do update, insert and even delete”. ► You can use the method str() to convert any other data type to string type. ► We can use bytearray too if we want to represent a sequence of letters as list.
  • 8. 2.4 Sets: A set is unordered collection of items inside curly braces {}. The object inside the list is non-changeable but the set can be modified by adding or removing an items. The set can contain items of different data types, each item inside the set is separated comma (,) and built in using the method set(). The difference between set and list is list items can be updated in place while set items are not. Ex: my_Set = { 100, b’B’, “Ali Sattar”, 20.5, (1, 2, 3) } ► Here as you can see, we created a set of different items and with a different data types. 2. The data type in python
  • 9. 2.The data type in python 2.5 Mapping: Dictionary is the only data type here, the dictionary is unordered collection of items (elements) where the items are surrounded by a curly braces too {} like set. Each item is separated by comma and it has a key: value pair. Dictionary items are changeable like list and bytearray. Ex: Diction1 = { 1: ‘Sunday’, 2: ‘Monday’, 3: ‘Tuesday’ } Diction2 = { ‘A’: ‘Apple’, ‘B’: ‘Bannana’, ‘C’: ‘Chocolate’ } Diction3 = { 12: ‘3*4’, 15: ‘3*5’}
  • 10. 3. Mutable vs. Immutable objects Mutable Object: It is the object in which it’s value can be changed. For example: list, bytearray, byte and dictionary. Immutable Object: It is the object in which it’s value cannot be changed. For example: int, float, str, tuple and set.