SlideShare a Scribd company logo
1 of 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

More Related Content

What's hot

Python data type
Python data typePython data type
Python data typenuripatidar
 
Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Python Functions Tutorial | Working With Functions In Python | Python Trainin...Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Python Functions Tutorial | Working With Functions In Python | Python Trainin...Edureka!
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python ProgrammingKamal Acharya
 
Python Libraries and Modules
Python Libraries and ModulesPython Libraries and Modules
Python Libraries and ModulesRaginiJain21
 
Introduction to Python Programming language.pptx
Introduction to Python Programming language.pptxIntroduction to Python Programming language.pptx
Introduction to Python Programming language.pptxBharathYusha1
 
Introduction To Python | Edureka
Introduction To Python | EdurekaIntroduction To Python | Edureka
Introduction To Python | EdurekaEdureka!
 
Python-01| Fundamentals
Python-01| FundamentalsPython-01| Fundamentals
Python-01| FundamentalsMohd Sajjad
 
Introduction to Python programming Language
Introduction to Python programming LanguageIntroduction to Python programming Language
Introduction to Python programming LanguageMansiSuthar3
 

What's hot (20)

Python Basics
Python BasicsPython Basics
Python Basics
 
Python Tutorial Part 1
Python Tutorial Part 1Python Tutorial Part 1
Python Tutorial Part 1
 
Python
PythonPython
Python
 
Python Intro
Python IntroPython Intro
Python Intro
 
Python programming : Files
Python programming : FilesPython programming : Files
Python programming : Files
 
Introduction to Python Basics Programming
Introduction to Python Basics ProgrammingIntroduction to Python Basics Programming
Introduction to Python Basics Programming
 
Python data type
Python data typePython data type
Python data type
 
Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Python Functions Tutorial | Working With Functions In Python | Python Trainin...Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Python Functions Tutorial | Working With Functions In Python | Python Trainin...
 
Python programming
Python  programmingPython  programming
Python programming
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python Programming
 
Python Libraries and Modules
Python Libraries and ModulesPython Libraries and Modules
Python Libraries and Modules
 
Introduction to Python Programming language.pptx
Introduction to Python Programming language.pptxIntroduction to Python Programming language.pptx
Introduction to Python Programming language.pptx
 
Introduction To Python | Edureka
Introduction To Python | EdurekaIntroduction To Python | Edureka
Introduction To Python | Edureka
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Python
PythonPython
Python
 
Python-01| Fundamentals
Python-01| FundamentalsPython-01| Fundamentals
Python-01| Fundamentals
 
Introduction to Python programming Language
Introduction to Python programming LanguageIntroduction to Python programming Language
Introduction to Python programming Language
 
Python basics
Python basicsPython basics
Python basics
 
Python dictionary
Python   dictionaryPython   dictionary
Python dictionary
 
Chapter 05 classes and objects
Chapter 05 classes and objectsChapter 05 classes and objects
Chapter 05 classes and objects
 

Similar to Presentation on python data type

Similar to Presentation on python data type (20)

Basic data types in python
Basic data types in pythonBasic data types in python
Basic data types in python
 
6031be43a4cf6255acb550cb0c1cf55e.pdf
6031be43a4cf6255acb550cb0c1cf55e.pdf6031be43a4cf6255acb550cb0c1cf55e.pdf
6031be43a4cf6255acb550cb0c1cf55e.pdf
 
Data types in python
Data types in pythonData types in python
Data types in python
 
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
 

Recently uploaded

Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 

Recently uploaded (20)

Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 

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.