Data-Handling
Data-Handling
PYTHON
Introduction
• In this chapter we will learn data types,
variables, operators and expression in
detail.
Graphical View
CORE
DATA TYPE
Floating
Integer Complex String Tuple List Dictionary
Point
Boolean
Mutable and Immutable Types
• In Python, Data Objects are categorized in two types-
• Mutable (Changeable)
• Immutable (Non-Changeable)
Look at following statements carefully-
p = 10
q=p they will represent 10, 10, 10
r = 10
Now, try to change the values-
p = 17
r=7 did the values actually change?
q =9
Answer is NO.
Because here values are objects and p, q, r are their reference name.
To understand it, lets see the next slide.
Variables and Values
An important fact to know is-
– In Python, values are actually objects.
– And their variable names are actually their reference names.
Suppose we assign 10 to a variable A.
A = 10
Here, value 10 is an object and A is its reference name.
10
Reference Object
variable
Variables and Values
If we assign 10 to a variable B,
B will refer to same object.
• Mutable (Changeable)
– lists, dictionaries and sets.
• Immutable (Non-Changeable)
– integers, floats, Booleans, strings and tuples.
Variable Internals
The Type of an Object
• In above given expression, first 7*8 will be calculated as 56, then 56 will
be divided by 5 and will result into 11.2, then 11.2 again divided by 2
and will result into 5.0.
Only in case of **, associativity will be followed
from right-to-left.
Above given example will be calculated as 3**(3**2). 3(9)
Expressions
• Python has following types of expression -