SlideShare uma empresa Scribd logo
1 de 15
1
PYTHON DATA TYPES
By: Swati Kushwaha
2
DATA TYPE
• Python data types are different in some aspects from
other programming languages.
• It is simple to understand and easy to use. Because
Python is interpreted programming language
• Python interpreter can determine which type of data
are storing,
33
THE DATA TYPE DETERMINES:
• The possible values for that type.
• The operations that can be done with that values.
• Conveys the meaning of data.
• The way values of that type can be stored.
44
DATA TYPES AVAILABLE IN PYTHON
• Everything in Python programming is an object, and each object has its own
unique identity(a type and a value).
• There are many native(built-in) data types available in Python.
Some important are:
• Numbers:.
• Sequences:.
• Boolean:
• Sets: .
• Dictionaries:.
55
MUTABLE AND IMMUTABLE OBJECTS
• Data objects of the above types are stored in a computer's memory for
processing. Some of these values can be modified during processing, but
contents of others can't be altered once they are created in the memory.
• Number values, strings, and tuple are immutable, which means their
contents can't be altered after creation.
• On the other hand, collection of items in a List or Dictionary object can be
modified. It is possible to add, delete, insert, and rearrange items in a list
or dictionary. Hence, they are mutable objects.
66
NUMERIC
A numeric value is any representation of data which has a numeric value. Python
identifies three types of numbers:
 Integer: Positive or negative whole numbers (without a fractional part)
 Float: Any real number with a floating point representation in which a fractional
component is denoted by a decimal symbol or scientific notation
 Complex number: A number with a real and imaginary component represented as
x+yj. x and y are floats and j is -1(square root of -1 called an imaginary number)
77
Built-in Function
Built-in Function Description
int
Returns the integer object from a float or a string containing
digits.
float
Returns a floating-point number object from a number or string
containing digits with decimal point or scientific notation.
complex
Returns a complex number with real and imaginary
components.
hex
Converts a decimal integer into a hexadecimal number with 0x
prefix.
oct
Converts a decimal integer in an octal representation with 0o
prefix.
pow Returns the power of the specified numbers.
abs
Returns the absolute value of a number without considering its
sign.
round Returns the rounded number
88
Boolean
• Data with one of two built-in values True or False. Notice that 'T'
and 'F' are capital.
• true and false are not valid booleans and Python will throw an error
for them.
99
SEQUENCE TYPE
A sequence is an ordered collection of similar or different data types. Python has the
following built-in sequence data types:
String: A string value is a collection of one or more characters put in single, double
or triple quotes.
List : A list object is an ordered collection of one or more data items, not necessarily
of the same type, put in square brackets.
Tuple: A Tuple object is an ordered collection of one or more data items, not
necessarily of the same type, put in parentheses.
1010
PYTHON - STRING
 A string object is one of the sequence data types in Python.
 It is an immutable sequence of Unicode characters.
 Strings are objects of Python's built-in class 'str'.
String literals are written by enclosing a sequence of characters in:-
• single quotes ('hello'),
• double quotes ("hello") or
• triple quotes ('''hello''' or """hello""")
>>> str1='hello'
>>> str1
'hello'
>>> str2="hello"
>>> str2
'hello'
>>> str3='''hello'''
>>> str3
'hello'
>>> str4="""hello"""
>>> str4
'hello'
1111
Python - List
In Python, the list is a collection of items of different data types. It is an ordered sequence of items
A list object contains one or more items, not necessarily of the same type, which are separated by comma and enclosed in
square brackets [].
Syntax:
list = [value1, value2, value3,...valueN]
The following declares a list type variable.
>>>names=["Jeff","Bill","Steve","Mohan"]
A list can also contain elements of different types.
>>>orderItem=[1,"Jeff","Computer",75.50,True]
1212
Python - Tuple
Tuple is a collection of items of any Python data type, same as the list type. Unlike the list, tuple is immutable.
The tuple object contains one or more items, of the same or different types, separated by comma and enclosed in
parentheses ().
Syntax:
tuple = (value1, value2, value3,...valueN)
The following declares a tuple type variable.
>>> names=("Jeff", "Bill", "Steve", "Mohan")
The tuple type can also contain elements of different types.
>>> orderItem=(1, "Jeff", "Computer", 75.50, True)
It is however not necessary to enclose the tuple elements in parentheses. The tuple object can include elements
separated by comma without parentheses.
>>> names="Jeff", "Bill", "Steve", "Mohan"
>>> type(names)
<class 'tuple'>
1313
PYTHON - SET
 A set is a collection of data types in Python, same as the list and tuple. However, it is not an ordered
collection of objects.
 The set is a Python implementation of the set in Mathematics.
 A set object has suitable methods to perform mathematical set operations like union, intersection,
difference, etc.
 A set object contains one or more items, not necessarily of the same type, which are separated by
comma and enclosed in curly brackets {}.
Syntax:
set = {value1, value2, value3,...valueN}
The following defines a set object.
>>> S1={1, "Bill", 75.50}
1414
DICTIONARY
A dictionary object is an unordered collection of data in a key:value pair
form. A collection of such pairs is enclosed in curly brackets.
For example: -
{1:"Steve", 2:"Bill", 3:"Ram", 4: "Farha"}
type() function
Python has an in-built function type() to ascertain the data type of a certain
value.
For example:-
enter type(1234) in Python shell and it will return <class 'int'>, which means
1234 is an integer value.
15
THANK YOU

Mais conteúdo relacionado

Mais procurados

9 big o-notation
9 big o-notation9 big o-notation
9 big o-notation
irdginfo
 
Full Python in 20 slides
Full Python in 20 slidesFull Python in 20 slides
Full Python in 20 slides
rfojdar
 
Set data structure
Set data structure Set data structure
Set data structure
Tech_MX
 

Mais procurados (20)

Tuples in Python
Tuples in PythonTuples in Python
Tuples in Python
 
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYA
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYAChapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYA
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYA
 
Python Functions
Python   FunctionsPython   Functions
Python Functions
 
Data types in python
Data types in pythonData types in python
Data types in python
 
Strings in Python
Strings in PythonStrings in Python
Strings in Python
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in python
 
Sorting
SortingSorting
Sorting
 
Python numbers
Python numbersPython numbers
Python numbers
 
Programming in c Arrays
Programming in c ArraysProgramming in c Arrays
Programming in c Arrays
 
9 big o-notation
9 big o-notation9 big o-notation
9 big o-notation
 
Python strings
Python stringsPython strings
Python strings
 
Python-03| Data types
Python-03| Data typesPython-03| Data types
Python-03| Data types
 
Numpy
NumpyNumpy
Numpy
 
Unit 4 python -list methods
Unit 4   python -list methodsUnit 4   python -list methods
Unit 4 python -list methods
 
Python : Data Types
Python : Data TypesPython : Data Types
Python : Data Types
 
Full Python in 20 slides
Full Python in 20 slidesFull Python in 20 slides
Full Python in 20 slides
 
NUMPY
NUMPY NUMPY
NUMPY
 
Set data structure
Set data structure Set data structure
Set data structure
 
Data Structures in Python
Data Structures in PythonData Structures in Python
Data Structures in Python
 
Python Modules
Python ModulesPython Modules
Python Modules
 

Semelhante a Presentation on python data type

Semelhante a Presentation on python data type (20)

6031be43a4cf6255acb550cb0c1cf55e.pdf
6031be43a4cf6255acb550cb0c1cf55e.pdf6031be43a4cf6255acb550cb0c1cf55e.pdf
6031be43a4cf6255acb550cb0c1cf55e.pdf
 
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
 
2. Values and Data types in Python.pptx
2. Values and Data types in Python.pptx2. Values and Data types in Python.pptx
2. Values and Data types in Python.pptx
 
Object reusability in python
Object reusability in pythonObject reusability in python
Object reusability in python
 
Chapter - 2.pptx
Chapter - 2.pptxChapter - 2.pptx
Chapter - 2.pptx
 
Python Datatypes by SujithKumar
Python Datatypes by SujithKumarPython Datatypes by SujithKumar
Python Datatypes by SujithKumar
 
Python-CH01L04-Presentation.pptx
Python-CH01L04-Presentation.pptxPython-CH01L04-Presentation.pptx
Python-CH01L04-Presentation.pptx
 
Python data type
Python data typePython data type
Python data type
 
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
 
PYTHON OBJECTS - Copy.pptx
 PYTHON OBJECTS - Copy.pptx PYTHON OBJECTS - Copy.pptx
PYTHON OBJECTS - Copy.pptx
 
Python
PythonPython
Python
 
python
pythonpython
python
 
Python Session - 3
Python Session - 3Python Session - 3
Python Session - 3
 
pythondatatypes.pptx
pythondatatypes.pptxpythondatatypes.pptx
pythondatatypes.pptx
 
UNIT-1(Lesson 5).pptx
UNIT-1(Lesson 5).pptxUNIT-1(Lesson 5).pptx
UNIT-1(Lesson 5).pptx
 
02python.ppt
02python.ppt02python.ppt
02python.ppt
 
02python.ppt
02python.ppt02python.ppt
02python.ppt
 
Data Types In Python.pptx
Data Types In Python.pptxData Types In Python.pptx
Data Types In Python.pptx
 
1. python programming
1. python programming1. python programming
1. python programming
 

Último

Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
MateoGardella
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
MateoGardella
 

Último (20)

APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.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
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
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
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
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"
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 

Presentation on python data type

  • 1. 1 PYTHON DATA TYPES By: Swati Kushwaha
  • 2. 2 DATA TYPE • Python data types are different in some aspects from other programming languages. • It is simple to understand and easy to use. Because Python is interpreted programming language • Python interpreter can determine which type of data are storing,
  • 3. 33 THE DATA TYPE DETERMINES: • The possible values for that type. • The operations that can be done with that values. • Conveys the meaning of data. • The way values of that type can be stored.
  • 4. 44 DATA TYPES AVAILABLE IN PYTHON • Everything in Python programming is an object, and each object has its own unique identity(a type and a value). • There are many native(built-in) data types available in Python. Some important are: • Numbers:. • Sequences:. • Boolean: • Sets: . • Dictionaries:.
  • 5. 55 MUTABLE AND IMMUTABLE OBJECTS • Data objects of the above types are stored in a computer's memory for processing. Some of these values can be modified during processing, but contents of others can't be altered once they are created in the memory. • Number values, strings, and tuple are immutable, which means their contents can't be altered after creation. • On the other hand, collection of items in a List or Dictionary object can be modified. It is possible to add, delete, insert, and rearrange items in a list or dictionary. Hence, they are mutable objects.
  • 6. 66 NUMERIC A numeric value is any representation of data which has a numeric value. Python identifies three types of numbers:  Integer: Positive or negative whole numbers (without a fractional part)  Float: Any real number with a floating point representation in which a fractional component is denoted by a decimal symbol or scientific notation  Complex number: A number with a real and imaginary component represented as x+yj. x and y are floats and j is -1(square root of -1 called an imaginary number)
  • 7. 77 Built-in Function Built-in Function Description int Returns the integer object from a float or a string containing digits. float Returns a floating-point number object from a number or string containing digits with decimal point or scientific notation. complex Returns a complex number with real and imaginary components. hex Converts a decimal integer into a hexadecimal number with 0x prefix. oct Converts a decimal integer in an octal representation with 0o prefix. pow Returns the power of the specified numbers. abs Returns the absolute value of a number without considering its sign. round Returns the rounded number
  • 8. 88 Boolean • Data with one of two built-in values True or False. Notice that 'T' and 'F' are capital. • true and false are not valid booleans and Python will throw an error for them.
  • 9. 99 SEQUENCE TYPE A sequence is an ordered collection of similar or different data types. Python has the following built-in sequence data types: String: A string value is a collection of one or more characters put in single, double or triple quotes. List : A list object is an ordered collection of one or more data items, not necessarily of the same type, put in square brackets. Tuple: A Tuple object is an ordered collection of one or more data items, not necessarily of the same type, put in parentheses.
  • 10. 1010 PYTHON - STRING  A string object is one of the sequence data types in Python.  It is an immutable sequence of Unicode characters.  Strings are objects of Python's built-in class 'str'. String literals are written by enclosing a sequence of characters in:- • single quotes ('hello'), • double quotes ("hello") or • triple quotes ('''hello''' or """hello""") >>> str1='hello' >>> str1 'hello' >>> str2="hello" >>> str2 'hello' >>> str3='''hello''' >>> str3 'hello' >>> str4="""hello""" >>> str4 'hello'
  • 11. 1111 Python - List In Python, the list is a collection of items of different data types. It is an ordered sequence of items A list object contains one or more items, not necessarily of the same type, which are separated by comma and enclosed in square brackets []. Syntax: list = [value1, value2, value3,...valueN] The following declares a list type variable. >>>names=["Jeff","Bill","Steve","Mohan"] A list can also contain elements of different types. >>>orderItem=[1,"Jeff","Computer",75.50,True]
  • 12. 1212 Python - Tuple Tuple is a collection of items of any Python data type, same as the list type. Unlike the list, tuple is immutable. The tuple object contains one or more items, of the same or different types, separated by comma and enclosed in parentheses (). Syntax: tuple = (value1, value2, value3,...valueN) The following declares a tuple type variable. >>> names=("Jeff", "Bill", "Steve", "Mohan") The tuple type can also contain elements of different types. >>> orderItem=(1, "Jeff", "Computer", 75.50, True) It is however not necessary to enclose the tuple elements in parentheses. The tuple object can include elements separated by comma without parentheses. >>> names="Jeff", "Bill", "Steve", "Mohan" >>> type(names) <class 'tuple'>
  • 13. 1313 PYTHON - SET  A set is a collection of data types in Python, same as the list and tuple. However, it is not an ordered collection of objects.  The set is a Python implementation of the set in Mathematics.  A set object has suitable methods to perform mathematical set operations like union, intersection, difference, etc.  A set object contains one or more items, not necessarily of the same type, which are separated by comma and enclosed in curly brackets {}. Syntax: set = {value1, value2, value3,...valueN} The following defines a set object. >>> S1={1, "Bill", 75.50}
  • 14. 1414 DICTIONARY A dictionary object is an unordered collection of data in a key:value pair form. A collection of such pairs is enclosed in curly brackets. For example: - {1:"Steve", 2:"Bill", 3:"Ram", 4: "Farha"} type() function Python has an in-built function type() to ascertain the data type of a certain value. For example:- enter type(1234) in Python shell and it will return <class 'int'>, which means 1234 is an integer value.