SlideShare una empresa de Scribd logo
1 de 17
Values and Data types
in Python
Prepared By,
P.Jothi Thilaga, AP/CSE
Ramco Institute of Technology
Rajapalayam
Value
one of the fundamental things, like a number, a
character or a string that program manipulates.
Example: a = 25, b= “Hi”
25, Hi represents values
Data type
refers to the type and size of data. Variables can
hold values of different data types. Python is a
purely object oriented language. It refers to
everything as an object, including numbers and
strings.
The five standard data types supported by python
includes:
Number
String
List
Tuple
Dictionary
Numbers
Number refers to a numeric value.
It includes
 integers
 long integers
 floating point
 complex numbers
Integers are whole numbers with no fractional parts.
They can be either positive, negative or zero value.
Long integers in python is displayed with an
uppercase L (56788333354533L is a long integer). -
supported only in python 2 version not in python 3.
Floating point numbers are numbers with fractions
or decimal points. Floating point values can be
expressed in scientific notation using the letter ‘e’ or
‘E’.
Complex number is a number that can be expressed
in the form a + bi, where a and b are real numbers,
and i is the imaginary unit.
Boolean is another data type in Python.
A variable of Boolean type can have one of
the two values - True or False.
The type() function can be used to know which data
type a variable or a value belongs to.
The isinstance() function to check if an object
belongs to a particular class.
Examples:
a = 5
print(a, "is of type", type(a))
a = 2.0
print(a, "is of type", type(a))
a = 1+2j
print(a, "is complex no.?", isinstance(1+2j,complex))
Output:
5 is of type <class 'int'>
2.0 is of type <class 'float'>
(1+2j) is complex no.? True
List
List is an ordered sequence of items. It is one
of the most used data type in Python and is
very flexible.
All the items in a list do not need to be of the
same type.
Lists are mutable. The elements in the list can
be modified.
To declare a list in python, separate the items
using commas and enclose them within square
brackets [ ].
>>> a = [1, 2.2, 'python'] The slicing operator [ ] is used
to extract an item or a range of items from a list. Index
starts from 0 in Python.
Examples:
>>>a = [5,10,15,20,25,30,35,40]
>>>a[2]
15
>>>print("a[0:3] = ", a[0:3])
a[0:3] = [5, 10, 15]
Tuple
Tuple is an ordered sequence of items same as
list. The only difference is that tuples are
immutable. Tuples once created cannot be
modified.
It is defined within parentheses ( ) where items
are separated by commas.
Example:
>>> t = (5, 'program', 1+3j, 4, 11.5)
print("t[1] = ", t[1])
print("t[0:3] = ", t[0:3])
Output:
t[1] = program
t[0:3] = (5, 'program', (1+3j))
Strings
A String in python can be a series or a
sequence of alphabets, numerals and special
characters.
Single quotes or double quotes are used to
represent strings.
>>> s = "This is a string"
Strings are immutable.
Examples:
s = 'Hello world!'
print("s[4] = ", s[4])
print("s[6:11] = ", s[6:11])
Output:
s[4] = o
s[6:11] = world
Dictionary
A python dictionary is an unordered collection
of key-value pairs.
Keys and values can be of any type in a
dictionary.
Items in dictionary are separated by comma
and enclosed with the curly-braces { }.
Example:
>>>dict={1:“hi”,2: “hello”}
Exercises
1. --------- are the reserved memory locations that stores
values.
2. What data type is used to store values in terms of key
and value?
(a) list
(b) tuple
(c) class
(d) dictionary
3. What data type is the object below ?
L = [1.0, 15, ‘hi’, 27]
(a) list
(b) dictionary
(c) array
(d) tuple
Answers
1. Variables
2. (d) dictionary
3. (a) list
Thank You

Más contenido relacionado

La actualidad más candente

Functions in python
Functions in pythonFunctions in python
Functions in pythoncolorsof
 
Introduction to the basics of Python programming (part 1)
Introduction to the basics of Python programming (part 1)Introduction to the basics of Python programming (part 1)
Introduction to the basics of Python programming (part 1)Pedro Rodrigues
 
Python variables and data types.pptx
Python variables and data types.pptxPython variables and data types.pptx
Python variables and data types.pptxAkshayAggarwal79
 
Looping Statements and Control Statements in Python
Looping Statements and Control Statements in PythonLooping Statements and Control Statements in Python
Looping Statements and Control Statements in PythonPriyankaC44
 
Basic Concepts in Python
Basic Concepts in PythonBasic Concepts in Python
Basic Concepts in PythonSumit Satam
 
Python-03| Data types
Python-03| Data typesPython-03| Data types
Python-03| Data typesMohd Sajjad
 
Variables & Data Types In Python | Edureka
Variables & Data Types In Python | EdurekaVariables & Data Types In Python | Edureka
Variables & Data Types In Python | EdurekaEdureka!
 
Functions in python slide share
Functions in python slide shareFunctions in python slide share
Functions in python slide shareDevashish Kumar
 
Python Programming Language | Python Classes | Python Tutorial | Python Train...
Python Programming Language | Python Classes | Python Tutorial | Python Train...Python Programming Language | Python Classes | Python Tutorial | Python Train...
Python Programming Language | Python Classes | Python Tutorial | Python Train...Edureka!
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in pythoneShikshak
 
Datastructures in python
Datastructures in pythonDatastructures in python
Datastructures in pythonhydpy
 

La actualidad más candente (20)

Loops in Python
Loops in PythonLoops in Python
Loops in Python
 
Python programming
Python  programmingPython  programming
Python programming
 
Functions in python
Functions in pythonFunctions in python
Functions in python
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Python for loop
Python for loopPython for loop
Python for loop
 
Introduction to the basics of Python programming (part 1)
Introduction to the basics of Python programming (part 1)Introduction to the basics of Python programming (part 1)
Introduction to the basics of Python programming (part 1)
 
Python variables and data types.pptx
Python variables and data types.pptxPython variables and data types.pptx
Python variables and data types.pptx
 
Python programming : Strings
Python programming : StringsPython programming : Strings
Python programming : Strings
 
Python ppt
Python pptPython ppt
Python ppt
 
Intro to Python
Intro to PythonIntro to Python
Intro to Python
 
Looping Statements and Control Statements in Python
Looping Statements and Control Statements in PythonLooping Statements and Control Statements in Python
Looping Statements and Control Statements in Python
 
Basic Concepts in Python
Basic Concepts in PythonBasic Concepts in Python
Basic Concepts in Python
 
Python-03| Data types
Python-03| Data typesPython-03| Data types
Python-03| Data types
 
Variables & Data Types In Python | Edureka
Variables & Data Types In Python | EdurekaVariables & Data Types In Python | Edureka
Variables & Data Types In Python | Edureka
 
Beginning Python Programming
Beginning Python ProgrammingBeginning Python Programming
Beginning Python Programming
 
Functions in python slide share
Functions in python slide shareFunctions in python slide share
Functions in python slide share
 
Python Programming Language | Python Classes | Python Tutorial | Python Train...
Python Programming Language | Python Classes | Python Tutorial | Python Train...Python Programming Language | Python Classes | Python Tutorial | Python Train...
Python Programming Language | Python Classes | Python Tutorial | Python Train...
 
Python programming
Python programmingPython programming
Python programming
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in python
 
Datastructures in python
Datastructures in pythonDatastructures in python
Datastructures in python
 

Similar a Values and 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.pptxdeivanayagamramachan
 
Python data type
Python data typePython data type
Python data typeJaya Kumari
 
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 kafssAliKhokhar33
 
Python quick guide
Python quick guidePython quick guide
Python quick guideHasan Bisri
 
The Datatypes Concept in Core Python.pptx
The Datatypes Concept in Core Python.pptxThe Datatypes Concept in Core Python.pptx
The Datatypes Concept in Core Python.pptxKavitha713564
 
Python 3 Programming Language
Python 3 Programming LanguagePython 3 Programming Language
Python 3 Programming LanguageTahani Al-Manie
 
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docxCS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docxfaithxdunce63732
 
Basic data types in python
Basic data types in pythonBasic data types in python
Basic data types in pythonsunilchute1
 
IMP PPT- Python programming fundamentals.pptx
IMP PPT- Python programming fundamentals.pptxIMP PPT- Python programming fundamentals.pptx
IMP PPT- Python programming fundamentals.pptxlemonchoos
 
C programming | Class 8 | III Term
C programming  | Class 8  | III TermC programming  | Class 8  | III Term
C programming | Class 8 | III TermAndrew Raj
 
parts_of_python_programming_language.pptx
parts_of_python_programming_language.pptxparts_of_python_programming_language.pptx
parts_of_python_programming_language.pptxKoteswari Kasireddy
 

Similar a Values and Data types in python (20)

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
 
Data Types In Python.pptx
Data Types In Python.pptxData Types In Python.pptx
Data Types In Python.pptx
 
Python PPT2
Python PPT2Python PPT2
Python PPT2
 
Python Session - 3
Python Session - 3Python Session - 3
Python Session - 3
 
Python data type
Python data typePython data type
Python data type
 
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
 
Chapter - 2.pptx
Chapter - 2.pptxChapter - 2.pptx
Chapter - 2.pptx
 
Python
PythonPython
Python
 
Python quick guide
Python quick guidePython quick guide
Python quick guide
 
Python
PythonPython
Python
 
Data types in python
Data types in pythonData types in python
Data types in python
 
The Datatypes Concept in Core Python.pptx
The Datatypes Concept in Core Python.pptxThe Datatypes Concept in Core Python.pptx
The Datatypes Concept in Core Python.pptx
 
Python 3 Programming Language
Python 3 Programming LanguagePython 3 Programming Language
Python 3 Programming Language
 
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docxCS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
 
Standard data-types-in-py
Standard data-types-in-pyStandard data-types-in-py
Standard data-types-in-py
 
types.pdf
types.pdftypes.pdf
types.pdf
 
Basic data types in python
Basic data types in pythonBasic data types in python
Basic data types in python
 
IMP PPT- Python programming fundamentals.pptx
IMP PPT- Python programming fundamentals.pptxIMP PPT- Python programming fundamentals.pptx
IMP PPT- Python programming fundamentals.pptx
 
C programming | Class 8 | III Term
C programming  | Class 8  | III TermC programming  | Class 8  | III Term
C programming | Class 8 | III Term
 
parts_of_python_programming_language.pptx
parts_of_python_programming_language.pptxparts_of_python_programming_language.pptx
parts_of_python_programming_language.pptx
 

Último

UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...Call Girls in Nagpur High Profile
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGMANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGSIVASHANKAR N
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 

Último (20)

UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGMANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 

Values and Data types in python

  • 1. Values and Data types in Python Prepared By, P.Jothi Thilaga, AP/CSE Ramco Institute of Technology Rajapalayam
  • 2. Value one of the fundamental things, like a number, a character or a string that program manipulates. Example: a = 25, b= “Hi” 25, Hi represents values Data type refers to the type and size of data. Variables can hold values of different data types. Python is a purely object oriented language. It refers to everything as an object, including numbers and strings.
  • 3. The five standard data types supported by python includes: Number String List Tuple Dictionary
  • 4. Numbers Number refers to a numeric value. It includes  integers  long integers  floating point  complex numbers
  • 5. Integers are whole numbers with no fractional parts. They can be either positive, negative or zero value. Long integers in python is displayed with an uppercase L (56788333354533L is a long integer). - supported only in python 2 version not in python 3. Floating point numbers are numbers with fractions or decimal points. Floating point values can be expressed in scientific notation using the letter ‘e’ or ‘E’. Complex number is a number that can be expressed in the form a + bi, where a and b are real numbers, and i is the imaginary unit.
  • 6. Boolean is another data type in Python. A variable of Boolean type can have one of the two values - True or False. The type() function can be used to know which data type a variable or a value belongs to. The isinstance() function to check if an object belongs to a particular class.
  • 7. Examples: a = 5 print(a, "is of type", type(a)) a = 2.0 print(a, "is of type", type(a)) a = 1+2j print(a, "is complex no.?", isinstance(1+2j,complex)) Output: 5 is of type <class 'int'> 2.0 is of type <class 'float'> (1+2j) is complex no.? True
  • 8. List List is an ordered sequence of items. It is one of the most used data type in Python and is very flexible. All the items in a list do not need to be of the same type. Lists are mutable. The elements in the list can be modified. To declare a list in python, separate the items using commas and enclose them within square brackets [ ].
  • 9. >>> a = [1, 2.2, 'python'] The slicing operator [ ] is used to extract an item or a range of items from a list. Index starts from 0 in Python. Examples: >>>a = [5,10,15,20,25,30,35,40] >>>a[2] 15 >>>print("a[0:3] = ", a[0:3]) a[0:3] = [5, 10, 15]
  • 10. Tuple Tuple is an ordered sequence of items same as list. The only difference is that tuples are immutable. Tuples once created cannot be modified. It is defined within parentheses ( ) where items are separated by commas.
  • 11. Example: >>> t = (5, 'program', 1+3j, 4, 11.5) print("t[1] = ", t[1]) print("t[0:3] = ", t[0:3]) Output: t[1] = program t[0:3] = (5, 'program', (1+3j))
  • 12. Strings A String in python can be a series or a sequence of alphabets, numerals and special characters. Single quotes or double quotes are used to represent strings. >>> s = "This is a string" Strings are immutable.
  • 13. Examples: s = 'Hello world!' print("s[4] = ", s[4]) print("s[6:11] = ", s[6:11]) Output: s[4] = o s[6:11] = world
  • 14. Dictionary A python dictionary is an unordered collection of key-value pairs. Keys and values can be of any type in a dictionary. Items in dictionary are separated by comma and enclosed with the curly-braces { }. Example: >>>dict={1:“hi”,2: “hello”}
  • 15. Exercises 1. --------- are the reserved memory locations that stores values. 2. What data type is used to store values in terms of key and value? (a) list (b) tuple (c) class (d) dictionary 3. What data type is the object below ? L = [1.0, 15, ‘hi’, 27] (a) list (b) dictionary (c) array (d) tuple
  • 16. Answers 1. Variables 2. (d) dictionary 3. (a) list