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

PPTX
CLASS OBJECT AND INHERITANCE IN PYTHON
PPTX
Variables in C++, data types in c++
PDF
Python Collections Tutorial | Edureka
PPTX
Polymorphism in Python
PPS
Wrapper class
PPTX
Introduction python
PPTX
Chapter 05 classes and objects
PPT
Packages in java
CLASS OBJECT AND INHERITANCE IN PYTHON
Variables in C++, data types in c++
Python Collections Tutorial | Edureka
Polymorphism in Python
Wrapper class
Introduction python
Chapter 05 classes and objects
Packages in java

What's hot (20)

PDF
Python-03| Data types
PPTX
Chapter 07 inheritance
PDF
Object-oriented Programming in Python
PDF
Managing I/O in c++
PDF
Classes and objects
PDF
Operator overloading C++
PPTX
Python-00 | Introduction and installing
PPTX
Python Data Structures and Algorithms.pptx
PPT
Files in c++ ppt
PPTX
Virtual base class
PPTX
C# File IO Operations
PPTX
Python list
PPTX
Python-Polymorphism.pptx
PPT
C++ Arrays
PPTX
Exception handling in c++
PPTX
Python 101: Python for Absolute Beginners (PyTexas 2014)
PPTX
C Programming Unit-4
PPTX
Introduction to Object Oriented Programming
Python-03| Data types
Chapter 07 inheritance
Object-oriented Programming in Python
Managing I/O in c++
Classes and objects
Operator overloading C++
Python-00 | Introduction and installing
Python Data Structures and Algorithms.pptx
Files in c++ ppt
Virtual base class
C# File IO Operations
Python list
Python-Polymorphism.pptx
C++ Arrays
Exception handling in c++
Python 101: Python for Absolute Beginners (PyTexas 2014)
C Programming Unit-4
Introduction to Object Oriented Programming
Ad

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

PDF
13- Data and Its Types presentation kafss
PDF
E-Notes_3720_Content_Document_20250107032323PM.pdf
PDF
4. Data Handling computer shcience pdf s
PPTX
Chapter - 2.pptx
PPTX
Python data type
PPTX
datatypes and its types.pptxgfmnghmghmfgm
PDF
Anton Kasyanov, Introduction to Python, Lecture4
PPTX
set.pptx
PPTX
Chapter 2-Programming Basics and Arrays.pptx Chapter 2-Programming Basics and...
PPTX
Python data type
PPTX
Modulebajajajjajaaja shejjsjs sisiisi 4.pptx
PPTX
11 Introduction to lists.pptx
PPTX
Presentation on python data type
PDF
COMPUTER SCIENCE SUPPORT MATERIAL CLASS 12.pdf
PPTX
The Datatypes Concept in Core Python.pptx
PPTX
pythondatatypes.pptx
PPTX
PYTHON LISTsjnjsnljnsjnosojnosojnsojnsjsn.pptx
PDF
Python for beginners
DOCX
unit 1.docx
PPTX
AI_2nd Lab.pptx
13- Data and Its Types presentation kafss
E-Notes_3720_Content_Document_20250107032323PM.pdf
4. Data Handling computer shcience pdf s
Chapter - 2.pptx
Python data type
datatypes and its types.pptxgfmnghmghmfgm
Anton Kasyanov, Introduction to Python, Lecture4
set.pptx
Chapter 2-Programming Basics and Arrays.pptx Chapter 2-Programming Basics and...
Python data type
Modulebajajajjajaaja shejjsjs sisiisi 4.pptx
11 Introduction to lists.pptx
Presentation on python data type
COMPUTER SCIENCE SUPPORT MATERIAL CLASS 12.pdf
The Datatypes Concept in Core Python.pptx
pythondatatypes.pptx
PYTHON LISTsjnjsnljnsjnosojnosojnsojnsjsn.pptx
Python for beginners
unit 1.docx
AI_2nd Lab.pptx
Ad

Recently uploaded (20)

PDF
Insight into Romanian Wild-Grown Heracleum sphondylium: Development of a New ...
DOCX
OA 7- Administrative Office Procedure and Management.docx
DOCX
HELMET DETECTION AND BIOMETRIC BASED VEHICLESECURITY USING MACHINE LEARNING.docx
PDF
GIÁO ÁN TIẾNG ANH 7 GLOBAL SUCCESS (CẢ NĂM) THEO CÔNG VĂN 5512 (2 CỘT) NĂM HỌ...
PPTX
MALARIA - educational ppt for students..
PDF
gsas-cvs-and-cover-letters jhvgfcffttfghgvhg.pdf
PDF
17649-Learning By Doing_text-tailieu.pdf
PDF
Bacterial Diversity and Evolution Bacterial Taxonomy Lecture (4)_.pdf
PDF
2003-theological-education-v39-n1-tai lieu
PDF
English 2nd semesteNotesh biology biopsy results from the other day and I jus...
PDF
Teacher's Day Quiz 2025
PDF
horaris de grups del curs 2025-2026 de l'institut
PDF
Physical pharmaceutics two in b pharmacy
PPTX
UCSP Section A - Human Cultural Variations,Social Differences,social ChangeCo...
PDF
BA-1ST(Education)-Education and Society.pdf
PPTX
Ppt obs emergecy.pptxydirnbduejguxjjdjidjdbuc
PPTX
Unit1_Kumod_deeplearning.pptx DEEP LEARNING
PDF
WHAT NURSES SAY_ COMMUNICATION BEHAVIORS ASSOCIATED WITH THE COMP.pdf
PDF
Financial Reporting and Analysis Using Financial Accounting Information by Ch...
PPTX
INTRODUCTION TO PHILOSOPHY FULL SEM - COMPLETE.pptxINTRODUCTION TO PHILOSOPHY...
Insight into Romanian Wild-Grown Heracleum sphondylium: Development of a New ...
OA 7- Administrative Office Procedure and Management.docx
HELMET DETECTION AND BIOMETRIC BASED VEHICLESECURITY USING MACHINE LEARNING.docx
GIÁO ÁN TIẾNG ANH 7 GLOBAL SUCCESS (CẢ NĂM) THEO CÔNG VĂN 5512 (2 CỘT) NĂM HỌ...
MALARIA - educational ppt for students..
gsas-cvs-and-cover-letters jhvgfcffttfghgvhg.pdf
17649-Learning By Doing_text-tailieu.pdf
Bacterial Diversity and Evolution Bacterial Taxonomy Lecture (4)_.pdf
2003-theological-education-v39-n1-tai lieu
English 2nd semesteNotesh biology biopsy results from the other day and I jus...
Teacher's Day Quiz 2025
horaris de grups del curs 2025-2026 de l'institut
Physical pharmaceutics two in b pharmacy
UCSP Section A - Human Cultural Variations,Social Differences,social ChangeCo...
BA-1ST(Education)-Education and Society.pdf
Ppt obs emergecy.pptxydirnbduejguxjjdjidjdbuc
Unit1_Kumod_deeplearning.pptx DEEP LEARNING
WHAT NURSES SAY_ COMMUNICATION BEHAVIORS ASSOCIATED WITH THE COMP.pdf
Financial Reporting and Analysis Using Financial Accounting Information by Ch...
INTRODUCTION TO PHILOSOPHY FULL SEM - COMPLETE.pptxINTRODUCTION TO PHILOSOPHY...

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.