6. Assignment statements
• A variable is a quantity that may change
within the context of a mathematical
problem or expression.
• In python a variable is created by assign
a value to it.
7. Assignment statements
a = 10
b = 20
c = a + b
word = “hello”
num = 20
num = 10
NUM = 20
nUM = 30
Num = 40
All are different
8. • Use letters
• Use numbers
with letters
• Use ‘_’ for
long names
Assignment statements
a = 5 a variable
A = 6 a variable
(note : A & a are different variables)
A 1 = 10 a variable
my_name = “Raja” a variable
9. • Don’t start
with number
• Don’t use
keywords as
variable
names
Assignment statements
2a = 100 syntax error
a2 = 100 is a variable
if = 5 is a syntax error
If = 5 If is a variable
True = 6 is a syntax error
true = 6 true is a variable
16. • An expression is a combination of
values, variables, and operators.
• Consider a=1, b=5, c=6, d=3.
Evaluate b – a * c / d + 10
Order of Operations
36. Types Conversions
a = “10” string
int(a) is 10 converted to integer
float(a) is 10.0 converted to float
b = 10.568 float
str(b) is “10.568” converted to string