SlideShare a Scribd company logo
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
List and Dictionary in python
Sangita Panchal
 
PDF
Python set
Mohammed Sikander
 
ODP
Python Modules
Nitin Reddy Katkam
 
PDF
Python-03| Data types
Mohd Sajjad
 
PPT
Python Dictionaries and Sets
Nicole Ryan
 
PPTX
Object oriented programming in python
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
How java differs from c and c++
shalinikarunakaran1
 
PPTX
Operator overloading
Ramish Suleman
 
List and Dictionary in python
Sangita Panchal
 
Python set
Mohammed Sikander
 
Python Modules
Nitin Reddy Katkam
 
Python-03| Data types
Mohd Sajjad
 
Python Dictionaries and Sets
Nicole Ryan
 
Object oriented programming in python
baabtra.com - No. 1 supplier of quality freshers
 
How java differs from c and c++
shalinikarunakaran1
 
Operator overloading
Ramish Suleman
 

What's hot (20)

PDF
Set methods in python
deepalishinkar1
 
PDF
Object oriented approach in python programming
Srinivas Narasegouda
 
PPT
Python List.ppt
T PRIYA
 
PPTX
Java input
Jin Castor
 
PDF
Strings in java
Kuppusamy P
 
PPTX
Python-Functions.pptx
Karudaiyar Ganapathy
 
PPTX
Member Function in C++
NikitaKaur10
 
PDF
Python list
Mohammed Sikander
 
PDF
Oops concepts || Object Oriented Programming Concepts in Java
Madishetty Prathibha
 
PPTX
Method overloading
Lovely Professional University
 
PDF
Python Variable Types, List, Tuple, Dictionary
Soba Arjun
 
PPTX
Unit 4 python -list methods
narmadhakin
 
PPTX
python.pptx
SabthamiS1
 
PPTX
Java Data Types
Spotle.ai
 
PPTX
Class 10
SIVASHANKARIRAJAN
 
PPTX
Vectors in Java
Abhilash Nair
 
PPTX
SQL Functions
ammarbrohi
 
PPTX
List in Python
Sharath Ankrajegowda
 
PPTX
Constructor and Types of Constructors
Dhrumil Panchal
 
Set methods in python
deepalishinkar1
 
Object oriented approach in python programming
Srinivas Narasegouda
 
Python List.ppt
T PRIYA
 
Java input
Jin Castor
 
Strings in java
Kuppusamy P
 
Python-Functions.pptx
Karudaiyar Ganapathy
 
Member Function in C++
NikitaKaur10
 
Python list
Mohammed Sikander
 
Oops concepts || Object Oriented Programming Concepts in Java
Madishetty Prathibha
 
Method overloading
Lovely Professional University
 
Python Variable Types, List, Tuple, Dictionary
Soba Arjun
 
Unit 4 python -list methods
narmadhakin
 
python.pptx
SabthamiS1
 
Java Data Types
Spotle.ai
 
Vectors in Java
Abhilash Nair
 
SQL Functions
ammarbrohi
 
List in Python
Sharath Ankrajegowda
 
Constructor and Types of Constructors
Dhrumil Panchal
 
Ad

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

PDF
4. Data Handling computer shcience pdf s
TonyTech2
 
PDF
Programming in Civil Engineering_UNIT 2_NOTES
Rushikesh Kolhe
 
PPTX
009 Data Handling class 11 -converted.pptx
adityakumar123456112
 
PPTX
introduction to python,datatypes,operators
MrANaveenKumar
 
PPTX
2. Values and Data types in Python.pptx
deivanayagamramachan
 
PPTX
Values and Data types in python
Jothi Thilaga P
 
PPTX
009 Data Handling .pptx
ssuser6c66f3
 
DOCX
unit 1.docx
ssuser2e84e4
 
PPTX
Data Types In Python.pptx
YatharthChaudhary5
 
PPTX
Data_Types_in_Python.pptx hubby outfit you bhi
bandiranvitha
 
PPTX
Presentation on python data type
swati kushwaha
 
PPTX
Basic data types in python
sunilchute1
 
PPTX
data typesppt.pptxcccccccccccccccccccccccccccccccccccccccccccccc
rajpalyadav13052024
 
PPTX
Data_Types_in_Python_Presentation (1).pptx
KousarNadaf2
 
PDF
Python for beginners
Ali Huseyn Aliyev
 
PDF
E-Notes_3720_Content_Document_20250107032323PM.pdf
aayushihirpara297
 
PPTX
IOT notes,................................
taetaebts431
 
PPTX
Cthhis_is_cybersecurty_and_cyber_sxec.pptx
sonawaneabhishek69
 
PPTX
Python Data-Types
Akhil Kaushik
 
4. Data Handling computer shcience pdf s
TonyTech2
 
Programming in Civil Engineering_UNIT 2_NOTES
Rushikesh Kolhe
 
009 Data Handling class 11 -converted.pptx
adityakumar123456112
 
introduction to python,datatypes,operators
MrANaveenKumar
 
2. Values and Data types in Python.pptx
deivanayagamramachan
 
Values and Data types in python
Jothi Thilaga P
 
009 Data Handling .pptx
ssuser6c66f3
 
unit 1.docx
ssuser2e84e4
 
Data Types In Python.pptx
YatharthChaudhary5
 
Data_Types_in_Python.pptx hubby outfit you bhi
bandiranvitha
 
Presentation on python data type
swati kushwaha
 
Basic data types in python
sunilchute1
 
data typesppt.pptxcccccccccccccccccccccccccccccccccccccccccccccc
rajpalyadav13052024
 
Data_Types_in_Python_Presentation (1).pptx
KousarNadaf2
 
Python for beginners
Ali Huseyn Aliyev
 
E-Notes_3720_Content_Document_20250107032323PM.pdf
aayushihirpara297
 
IOT notes,................................
taetaebts431
 
Cthhis_is_cybersecurty_and_cyber_sxec.pptx
sonawaneabhishek69
 
Python Data-Types
Akhil Kaushik
 
Ad

Recently uploaded (20)

PDF
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
PPTX
Software Engineering BSC DS UNIT 1 .pptx
Dr. Pallawi Bulakh
 
PPTX
PPTs-The Rise of Empiresghhhhhhhh (1).pptx
academysrusti114
 
PDF
Landforms and landscapes data surprise preview
jpinnuck
 
PPTX
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
PDF
Wings of Fire Book by Dr. A.P.J Abdul Kalam Full PDF
hetalvaishnav93
 
PDF
PG-BPSDMP 2 TAHUN 2025PG-BPSDMP 2 TAHUN 2025.pdf
AshifaRamadhani
 
PPTX
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
PDF
UTS Health Student Promotional Representative_Position Description.pdf
Faculty of Health, University of Technology Sydney
 
PDF
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
PDF
Phylum Arthropoda: Characteristics and Classification, Entomology Lecture
Miraj Khan
 
PPTX
How to Manage Global Discount in Odoo 18 POS
Celine George
 
PDF
Exploring-Forces 5.pdf/8th science curiosity/by sandeep swamy notes/ppt
Sandeep Swamy
 
PPTX
PREVENTIVE PEDIATRIC. pptx
AneetaSharma15
 
PPTX
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
PPTX
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
PPTX
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
PDF
7.Particulate-Nature-of-Matter.ppt/8th class science curiosity/by k sandeep s...
Sandeep Swamy
 
PDF
Sunset Boulevard Student Revision Booklet
jpinnuck
 
PPTX
IMMUNIZATION PROGRAMME pptx
AneetaSharma15
 
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
Software Engineering BSC DS UNIT 1 .pptx
Dr. Pallawi Bulakh
 
PPTs-The Rise of Empiresghhhhhhhh (1).pptx
academysrusti114
 
Landforms and landscapes data surprise preview
jpinnuck
 
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
Wings of Fire Book by Dr. A.P.J Abdul Kalam Full PDF
hetalvaishnav93
 
PG-BPSDMP 2 TAHUN 2025PG-BPSDMP 2 TAHUN 2025.pdf
AshifaRamadhani
 
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
UTS Health Student Promotional Representative_Position Description.pdf
Faculty of Health, University of Technology Sydney
 
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
Phylum Arthropoda: Characteristics and Classification, Entomology Lecture
Miraj Khan
 
How to Manage Global Discount in Odoo 18 POS
Celine George
 
Exploring-Forces 5.pdf/8th science curiosity/by sandeep swamy notes/ppt
Sandeep Swamy
 
PREVENTIVE PEDIATRIC. pptx
AneetaSharma15
 
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
7.Particulate-Nature-of-Matter.ppt/8th class science curiosity/by k sandeep s...
Sandeep Swamy
 
Sunset Boulevard Student Revision Booklet
jpinnuck
 
IMMUNIZATION PROGRAMME pptx
AneetaSharma15
 

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.