SlideShare a Scribd company logo
9
Most read
10
Most read
21
Most read
Datatypes
In Python
Mrs.N.Kavitha
Head,Department of Computer Science,
E.M.G.Yadava Women’s College
Madurai-14.
Content
Introduction
Types of datatype
Numeric
Set
Boolean
None
Sequence
Mapping
Introduction
 Data types are the classification or categorization of data items. It
represents the kind of value that tells what operations can be performed on
a particular data. Since everything is an object in Python programming
data types are actually classes and variables are instances (object) of these
classes.
 To define the values ​​of various data types and check their data types
we use the type() function.
Types of Datatype
Numeric
 The numeric data type in Python represents the data that has a numeric value. A
numeric value can be an integer , float or complex.
 Integers – This value is represented by int class. It contains positive or negative
whole numbers (without fractions or decimals). In Python, there is no limit to
how long an integer value can be.
 Float – This value is represented by the float class. It is a real number with a
floating-point representation. It is specified by a decimal point. Optionally, the
character e or E followed by a positive or negative integer may be appended to
specify scientific notation.
 Complex Numbers – Complex number is represented by a complex class. It is
specified as (real part) + (imaginary part) j.
For Example
a = 5
print("Type of a: ", type(a))
b = 5.0
print("nType of b: ", type(b))
c = 2 + 4j
print("nType of c: ", type(c))
Output
Type of a: <class ‘int’>
Type of b: <class ‘float’>
Type of c: <class ‘complex’>
Sets
 A set is an unordered collection of elements much like a set in Mathematics.
 The order of elements is not maintained in the sets. It means the elements may
not appear in the same order as they are entered into the set.
 A set does not accept duplicate elements.
 There are two sub types in sets:
set datatype
frozen set datatype
Set datatypes
 To create a set , we should enter the elements separated by commas inside
curly braces{}.
 For example
s={12,13,12,14,15} Output
print(s) {14,12,13,15}
 Here the set ‘s’ is not maintaining the order of the elements.
 we repeated the element 12 in the set, but it stored only one 12.
Frozenset Datatype
 The frozenset datatype is same as the set datatype.
 The main difference is that the elements in the set datatype can be modified;
the elements of frozen set cannot be modified.
 For example
Output
s={50,60,70,80,90} {80,90,50,60,70}
print(s)
fs=frozenset(s) ({80,90,50,60,70})
print(fs)
fs= frozenset(abcdefg) ({ ‘e’, ’g’, ’f’ , ’d’, ’a’ , ’c’, ’b’})
print(fs)
Boolean
 The bool datatype in python represents Boolean values.
 There are only two Boolean values True or False that can be represented by
this datatype.
 Python internally represents True as 1 and False as 0. A blank string like “” is
also represented as False.
 For example
a=10 Output
b=20 Hello
if (a<b):
print(‘Hello’)
None
 In python, the ‘None’ datatype represents an object that does not contain any
values.
 In languages like Java, it is called ‘Null’ object . But in Python, it is called ‘None’
object.
 One of the uses of ‘None’ is that it is used inside a function as a default value of
the arguments.
 When calling the function, if no value is passed , then the default value will be
taken as ‘None’.
Sequence
 A Sequence represents a group of elements or item.
 For example , a group of integer numbers will form a sequence.
 There are six types of sequences in Python:
str
bytes
bytearray
list
tuple
range
str
 In Python , str represents string datatype.
 A string is represented by a group of characters.
 String are enclosed in single quotes ’’ or double quotes “”.
 For example
Output
str=“Hai” Hai
str=‘Hi’ Hi
For Example
s=‘Lets learn python’ Output
print(s) Lets learn python
print(s[0]) L
print(s[0:5]) Lets
print(s[12: ]) python
print(s[-2]) o
Bytes
 The bytes represents a group of byte numbers just like an array does.
 A byte number is any positive integer from 0 to 255
 Bytes array can store numbers in the range from 0 to 255 and it cannot even
store negative numbers.
 For example
elements =[10,20,0,40,15] Output
x=bytes(elements) 10
print(x[0])
Bytearray
 The bytearray datatype is similar to bytes datatype.
 The difference is that the bytes type array cannot be modified but the
bytearray type array can be modified.
 For example
elements=[10,20,0,40,15] Output
x=bytearray(elements)
print (x[0]) 10
x[0]=88
x[1]=99 88,99,0,40,50
print(x)
List
 A list is a collection of different types of datatype values or items.
 Since Python lists are mutable, we can change their elements after forming.
 The comma (,) and the square brackets [enclose the List's items] serve as
separators.
 Lists are created using square brackets.
 For example
list = ["apple", "banana", "cherry"]
print(list)
For Example
list1 = [1, 2, "Python", "Program", 15.9] Output
list2 = ["Amy", "Ryan", "Henry", "Emma"]
[1, 2,”Python”, “Program”, 15.9]
print(list1) [“Amy ”, ”Ryan ”,” Henry” ,” Emma”]
print(list2)
2
print(list1[1]) Amy
print(list2[0])
Tuple
 A tuple is a collection of objects which ordered and immutable.
 Tuples are sequences, just like lists. The differences between tuples and
lists are, the tuples cannot be changed and the lists can be change.
 Unlike lists and tuples use parentheses, whereas lists use square
brackets.
 Tuples are immutable which means you cannot update or change the
values of tuple elements. You are able to take portions of existing tuples
to create new tuples
For Example
tup1 = ('physics', 'chemistry', 1997, 2000) Output
tup2 = (1, 2, 3, 4, 5, 6, 7 )
print (tup1[0]) physics
print (tup2[1:5]) [2, 3, 4, 5]
Range
 Python range() is an in-built function in Python which returns a sequence of
numbers starting from 0 and increments to 1 until it reaches a specified number.
 We use range() function with for and while loop to generate a sequence of
numbers. Following is the syntax of the function:
 range(start, stop, step)
 Here is the description of the parameters used:
start: Integer number to specify starting position, (Its optional, Default: 0)
stop: Integer number to specify starting position (It's mandatory)
step: Integer number to specify increment, (Its optional, Default: 1)
For Example
for i in range(5): Output
print(i) 0 1 2 3 4
for i in range(1, 5):
print(i) 1 2 3 4
for i in range(1, 5, 2):
print(i) 1 3
Mapping
 Python Dictionary is an unordered sequence of data of key-value pair
form. It is similar to the hash table type.
 Dictionaries are written within curly braces in the form {key : value} .
 It is very useful to retrieve data in an optimized way among a large
amount of data.
dict={001: RDJ}
Key Value
For Example
a = {1:“RDJ", 2:“JD“ , "age":33} Output
print(a[1]) RDJ
print(a[2]) JD
print(a["age"]) 33

More Related Content

PPTX
Inferential statistics powerpoint
kellula
 
PPTX
Hypothesis testing
Madhuranath R
 
PPTX
Panel data analysis
Sana Hassan Afridi
 
PPTX
Dimensional approach
Andrew Scott
 
PDF
Spss tutorial 1
kunkumabala
 
PPTX
Chapter 02 functions -class xii
Praveen M Jigajinni
 
PPTX
Regular expressions in Python
Sujith Kumar
 
PDF
List,tuple,dictionary
nitamhaske
 
Inferential statistics powerpoint
kellula
 
Hypothesis testing
Madhuranath R
 
Panel data analysis
Sana Hassan Afridi
 
Dimensional approach
Andrew Scott
 
Spss tutorial 1
kunkumabala
 
Chapter 02 functions -class xii
Praveen M Jigajinni
 
Regular expressions in Python
Sujith Kumar
 
List,tuple,dictionary
nitamhaske
 

What's hot (20)

PPTX
Spearman’s rank correlation (1)
PritikaNeupane
 
DOCX
Practical File of C Language
RAJWANT KAUR
 
PPTX
Python variables and data types.pptx
AkshayAggarwal79
 
PDF
M.Phil thesis by S.Lakshmanan
LAKSHMANAN S
 
PPTX
class and objects
Payel Guria
 
PPT
R studio
Kinza Irshad
 
PPTX
C programing -Structure
shaibal sharif
 
PDF
Data visualization in Python
Marc Garcia
 
PPTX
Dictionary in python
vikram mahendra
 
PPT
SmartPLS presentation
unespguara
 
PPTX
Functions in C
Kamal Acharya
 
PDF
Introduction to R
Kazuki Yoshida
 
PPT
1634 time series and trend analysis
Dr Fereidoun Dejahang
 
PPTX
Factor analysis
saba khan
 
PPT
Humanist perspective
Seemi Jamil
 
PDF
Hypothesis testing
Kaori Kubo Germano, PhD
 
PPTX
2.3 stem and leaf displays
leblance
 
PPTX
Python dictionary
eman lotfy
 
PPTX
Data analysis with R
ShareThis
 
PPTX
Presentation on C Switch Case Statements
Dipesh Panday
 
Spearman’s rank correlation (1)
PritikaNeupane
 
Practical File of C Language
RAJWANT KAUR
 
Python variables and data types.pptx
AkshayAggarwal79
 
M.Phil thesis by S.Lakshmanan
LAKSHMANAN S
 
class and objects
Payel Guria
 
R studio
Kinza Irshad
 
C programing -Structure
shaibal sharif
 
Data visualization in Python
Marc Garcia
 
Dictionary in python
vikram mahendra
 
SmartPLS presentation
unespguara
 
Functions in C
Kamal Acharya
 
Introduction to R
Kazuki Yoshida
 
1634 time series and trend analysis
Dr Fereidoun Dejahang
 
Factor analysis
saba khan
 
Humanist perspective
Seemi Jamil
 
Hypothesis testing
Kaori Kubo Germano, PhD
 
2.3 stem and leaf displays
leblance
 
Python dictionary
eman lotfy
 
Data analysis with R
ShareThis
 
Presentation on C Switch Case Statements
Dipesh Panday
 
Ad

Similar to The Datatypes Concept in Core Python.pptx (20)

PDF
Datatypes in python
eShikshak
 
PPTX
Presentation on python data type
swati kushwaha
 
PPTX
Data types in python
RaginiJain21
 
PPTX
PYTHON DATA TYPE in python using v .pptx
urvashipundir04
 
PDF
13- Data and Its Types presentation kafss
AliKhokhar33
 
PDF
E-Notes_3720_Content_Document_20250107032323PM.pdf
aayushihirpara297
 
PPTX
Python Session - 3
AnirudhaGaikwad4
 
PPTX
Python
reshmaravichandran
 
PPTX
IOT notes,................................
taetaebts431
 
PPTX
Data Types In Python.pptx
YatharthChaudhary5
 
PPTX
PYTHON DATA TYPE IN PROGRAMMING LANG.pptx
urvashipundir04
 
PDF
Datatypes in Python.pdf
king931283
 
PPTX
Data_Types_in_Python.pptx hubby outfit you bhi
bandiranvitha
 
PDF
4. Data Handling computer shcience pdf s
TonyTech2
 
PPTX
Basic data types in python
sunilchute1
 
DOCX
unit 1.docx
ssuser2e84e4
 
PPTX
1-Introduction to Python, features of python, history of python(1).pptx
MAHESWARIS55
 
PPTX
pythondatatypes.pptx
ArchanaAravind1
 
PDF
Python-03| Data types
Mohd Sajjad
 
Datatypes in python
eShikshak
 
Presentation on python data type
swati kushwaha
 
Data types in python
RaginiJain21
 
PYTHON DATA TYPE in python using v .pptx
urvashipundir04
 
13- Data and Its Types presentation kafss
AliKhokhar33
 
E-Notes_3720_Content_Document_20250107032323PM.pdf
aayushihirpara297
 
Python Session - 3
AnirudhaGaikwad4
 
IOT notes,................................
taetaebts431
 
Data Types In Python.pptx
YatharthChaudhary5
 
PYTHON DATA TYPE IN PROGRAMMING LANG.pptx
urvashipundir04
 
Datatypes in Python.pdf
king931283
 
Data_Types_in_Python.pptx hubby outfit you bhi
bandiranvitha
 
4. Data Handling computer shcience pdf s
TonyTech2
 
Basic data types in python
sunilchute1
 
unit 1.docx
ssuser2e84e4
 
1-Introduction to Python, features of python, history of python(1).pptx
MAHESWARIS55
 
pythondatatypes.pptx
ArchanaAravind1
 
Python-03| Data types
Mohd Sajjad
 
Ad

More from Kavitha713564 (16)

PPTX
Python Virtual Machine concept- N.Kavitha.pptx
Kavitha713564
 
PPTX
Operators Concept in Python-N.Kavitha.pptx
Kavitha713564
 
PPTX
THE PACKAGES CONCEPT IN JAVA PROGRAMMING.pptx
Kavitha713564
 
PPTX
The Java Server Page in Java Concept.pptx
Kavitha713564
 
PPTX
Programming in python in detail concept .pptx
Kavitha713564
 
PPTX
The Input Statement in Core Python .pptx
Kavitha713564
 
PPTX
Packages in java
Kavitha713564
 
PPTX
Interface in java
Kavitha713564
 
PPTX
Exception handling in java
Kavitha713564
 
PPTX
Multithreading in java
Kavitha713564
 
DOCX
Methods in Java
Kavitha713564
 
PPTX
Applet in java new
Kavitha713564
 
PPTX
Basic of java
Kavitha713564
 
PPTX
Multithreading in java
Kavitha713564
 
PPTX
Input output files in java
Kavitha713564
 
PPTX
Arrays,string and vector
Kavitha713564
 
Python Virtual Machine concept- N.Kavitha.pptx
Kavitha713564
 
Operators Concept in Python-N.Kavitha.pptx
Kavitha713564
 
THE PACKAGES CONCEPT IN JAVA PROGRAMMING.pptx
Kavitha713564
 
The Java Server Page in Java Concept.pptx
Kavitha713564
 
Programming in python in detail concept .pptx
Kavitha713564
 
The Input Statement in Core Python .pptx
Kavitha713564
 
Packages in java
Kavitha713564
 
Interface in java
Kavitha713564
 
Exception handling in java
Kavitha713564
 
Multithreading in java
Kavitha713564
 
Methods in Java
Kavitha713564
 
Applet in java new
Kavitha713564
 
Basic of java
Kavitha713564
 
Multithreading in java
Kavitha713564
 
Input output files in java
Kavitha713564
 
Arrays,string and vector
Kavitha713564
 

Recently uploaded (20)

PPTX
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
PPTX
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
PPTX
Gupta Art & Architecture Temple and Sculptures.pptx
Virag Sontakke
 
PPTX
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
PPTX
BASICS IN COMPUTER APPLICATIONS - UNIT I
suganthim28
 
PDF
Module 2: Public Health History [Tutorial Slides]
JonathanHallett4
 
PPTX
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
PPTX
An introduction to Dialogue writing.pptx
drsiddhantnagine
 
PPTX
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
PPTX
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
PPTX
How to Close Subscription in Odoo 18 - Odoo Slides
Celine George
 
PPTX
PROTIEN ENERGY MALNUTRITION: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
PPTX
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
 
PPTX
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
PPTX
CONCEPT OF CHILD CARE. pptx
AneetaSharma15
 
PPTX
Applications of matrices In Real Life_20250724_091307_0000.pptx
gehlotkrish03
 
PDF
Virat Kohli- the Pride of Indian cricket
kushpar147
 
PPTX
How to Track Skills & Contracts Using Odoo 18 Employee
Celine George
 
PDF
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
PPTX
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
Gupta Art & Architecture Temple and Sculptures.pptx
Virag Sontakke
 
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
BASICS IN COMPUTER APPLICATIONS - UNIT I
suganthim28
 
Module 2: Public Health History [Tutorial Slides]
JonathanHallett4
 
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
An introduction to Dialogue writing.pptx
drsiddhantnagine
 
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
How to Close Subscription in Odoo 18 - Odoo Slides
Celine George
 
PROTIEN ENERGY MALNUTRITION: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
 
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
CONCEPT OF CHILD CARE. pptx
AneetaSharma15
 
Applications of matrices In Real Life_20250724_091307_0000.pptx
gehlotkrish03
 
Virat Kohli- the Pride of Indian cricket
kushpar147
 
How to Track Skills & Contracts Using Odoo 18 Employee
Celine George
 
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 

The Datatypes Concept in Core Python.pptx

  • 1. Datatypes In Python Mrs.N.Kavitha Head,Department of Computer Science, E.M.G.Yadava Women’s College Madurai-14.
  • 3. Introduction  Data types are the classification or categorization of data items. It represents the kind of value that tells what operations can be performed on a particular data. Since everything is an object in Python programming data types are actually classes and variables are instances (object) of these classes.  To define the values ​​of various data types and check their data types we use the type() function.
  • 5. Numeric  The numeric data type in Python represents the data that has a numeric value. A numeric value can be an integer , float or complex.  Integers – This value is represented by int class. It contains positive or negative whole numbers (without fractions or decimals). In Python, there is no limit to how long an integer value can be.  Float – This value is represented by the float class. It is a real number with a floating-point representation. It is specified by a decimal point. Optionally, the character e or E followed by a positive or negative integer may be appended to specify scientific notation.  Complex Numbers – Complex number is represented by a complex class. It is specified as (real part) + (imaginary part) j.
  • 6. For Example a = 5 print("Type of a: ", type(a)) b = 5.0 print("nType of b: ", type(b)) c = 2 + 4j print("nType of c: ", type(c)) Output Type of a: <class ‘int’> Type of b: <class ‘float’> Type of c: <class ‘complex’>
  • 7. Sets  A set is an unordered collection of elements much like a set in Mathematics.  The order of elements is not maintained in the sets. It means the elements may not appear in the same order as they are entered into the set.  A set does not accept duplicate elements.  There are two sub types in sets: set datatype frozen set datatype
  • 8. Set datatypes  To create a set , we should enter the elements separated by commas inside curly braces{}.  For example s={12,13,12,14,15} Output print(s) {14,12,13,15}  Here the set ‘s’ is not maintaining the order of the elements.  we repeated the element 12 in the set, but it stored only one 12.
  • 9. Frozenset Datatype  The frozenset datatype is same as the set datatype.  The main difference is that the elements in the set datatype can be modified; the elements of frozen set cannot be modified.  For example Output s={50,60,70,80,90} {80,90,50,60,70} print(s) fs=frozenset(s) ({80,90,50,60,70}) print(fs) fs= frozenset(abcdefg) ({ ‘e’, ’g’, ’f’ , ’d’, ’a’ , ’c’, ’b’}) print(fs)
  • 10. Boolean  The bool datatype in python represents Boolean values.  There are only two Boolean values True or False that can be represented by this datatype.  Python internally represents True as 1 and False as 0. A blank string like “” is also represented as False.  For example a=10 Output b=20 Hello if (a<b): print(‘Hello’)
  • 11. None  In python, the ‘None’ datatype represents an object that does not contain any values.  In languages like Java, it is called ‘Null’ object . But in Python, it is called ‘None’ object.  One of the uses of ‘None’ is that it is used inside a function as a default value of the arguments.  When calling the function, if no value is passed , then the default value will be taken as ‘None’.
  • 12. Sequence  A Sequence represents a group of elements or item.  For example , a group of integer numbers will form a sequence.  There are six types of sequences in Python: str bytes bytearray list tuple range
  • 13. str  In Python , str represents string datatype.  A string is represented by a group of characters.  String are enclosed in single quotes ’’ or double quotes “”.  For example Output str=“Hai” Hai str=‘Hi’ Hi
  • 14. For Example s=‘Lets learn python’ Output print(s) Lets learn python print(s[0]) L print(s[0:5]) Lets print(s[12: ]) python print(s[-2]) o
  • 15. Bytes  The bytes represents a group of byte numbers just like an array does.  A byte number is any positive integer from 0 to 255  Bytes array can store numbers in the range from 0 to 255 and it cannot even store negative numbers.  For example elements =[10,20,0,40,15] Output x=bytes(elements) 10 print(x[0])
  • 16. Bytearray  The bytearray datatype is similar to bytes datatype.  The difference is that the bytes type array cannot be modified but the bytearray type array can be modified.  For example elements=[10,20,0,40,15] Output x=bytearray(elements) print (x[0]) 10 x[0]=88 x[1]=99 88,99,0,40,50 print(x)
  • 17. List  A list is a collection of different types of datatype values or items.  Since Python lists are mutable, we can change their elements after forming.  The comma (,) and the square brackets [enclose the List's items] serve as separators.  Lists are created using square brackets.  For example list = ["apple", "banana", "cherry"] print(list)
  • 18. For Example list1 = [1, 2, "Python", "Program", 15.9] Output list2 = ["Amy", "Ryan", "Henry", "Emma"] [1, 2,”Python”, “Program”, 15.9] print(list1) [“Amy ”, ”Ryan ”,” Henry” ,” Emma”] print(list2) 2 print(list1[1]) Amy print(list2[0])
  • 19. Tuple  A tuple is a collection of objects which ordered and immutable.  Tuples are sequences, just like lists. The differences between tuples and lists are, the tuples cannot be changed and the lists can be change.  Unlike lists and tuples use parentheses, whereas lists use square brackets.  Tuples are immutable which means you cannot update or change the values of tuple elements. You are able to take portions of existing tuples to create new tuples
  • 20. For Example tup1 = ('physics', 'chemistry', 1997, 2000) Output tup2 = (1, 2, 3, 4, 5, 6, 7 ) print (tup1[0]) physics print (tup2[1:5]) [2, 3, 4, 5]
  • 21. Range  Python range() is an in-built function in Python which returns a sequence of numbers starting from 0 and increments to 1 until it reaches a specified number.  We use range() function with for and while loop to generate a sequence of numbers. Following is the syntax of the function:  range(start, stop, step)  Here is the description of the parameters used: start: Integer number to specify starting position, (Its optional, Default: 0) stop: Integer number to specify starting position (It's mandatory) step: Integer number to specify increment, (Its optional, Default: 1)
  • 22. For Example for i in range(5): Output print(i) 0 1 2 3 4 for i in range(1, 5): print(i) 1 2 3 4 for i in range(1, 5, 2): print(i) 1 3
  • 23. Mapping  Python Dictionary is an unordered sequence of data of key-value pair form. It is similar to the hash table type.  Dictionaries are written within curly braces in the form {key : value} .  It is very useful to retrieve data in an optimized way among a large amount of data. dict={001: RDJ} Key Value
  • 24. For Example a = {1:“RDJ", 2:“JD“ , "age":33} Output print(a[1]) RDJ print(a[2]) JD print(a["age"]) 33