42-81 getting started with python and python fundamentals online
42-81 getting started with python and python fundamentals online
NUMERIC
LITERALS
UNARY BINARY
IDENTITY ARITHMETIC
LOGICAL RELATIONAL
MEMBERSHIP ASSIGNMENT
PYTHON PUNCTUATORS
‘ “ # \ () [] {} @ , : . =
PYTHON COMMENTS
Front loaded
data space
print(id(num1))
print(id(num1))
num1 20
num2
num3 20.0
20.0
num4
num5 20.0
>>> i=0.1
>>> print(i*3==0.3)
False
>>> print(0.1+0.2)
0.30000000000000004
>>>
PYTHON VARIABLES [LVALUE AND RVALUE]
C=b
PYTHON VARIABLES
10
c b
PYTHON VARIABLES
Swapping (interchanging) values of variables
PYTHON VARIABLES
PYTHON VARIABLES
PYTHON VARIABLES
TASK: PYTHON VARIABLES
A variable is not
created until
some value is
assigned to it
A variable pointing to a
value of a certain type, can
be made to point to a
value/object of different
type. This is called dynamic
typing.
In this case python will not
raise any error.
Type(object name) function is used to
determine the type of an object.
Object can be a variable or a literal.
Caution with DYNAMIC TYPING
Although python is
comfortable with changing
types of a variable, the
programmer is responsible
for ensuring right types for
certain types of operations.
TASK
Which data type will be used to represent the following data values and why?