Professional Documents
Culture Documents
PYTHON CHAP 2 - Operating On Variables
PYTHON CHAP 2 - Operating On Variables
Operating on variables
Calculation directly with
numbers
Today Sofie produce 520
cupcakes. Each cupcake costing
RM 25. Find how much she earn?
Today Sofie produce 520
cupcakes. Each cupcake costing
RM 25. Find how much she earn?
Today Sofie produce 520
cupcakes. Each cupcake costing
RM 25. Find how much she earn?
Today Sofie produce 520
cupcakes. Each cupcake costing
RM 25. Find how much she earn?
Today Sofie produce 520
cupcakes. Each cupcake costing
RM 25. Find how much she earn?
Calculation directly with numbers
Calculation with Variables
Variables ?
Example :
• Name place holder
x=2
• Hold and use later
value = 32
• Like storing value
name = ‘sasi’
1. Letters / number /
Variables have 2.
underscore
Can’t have space
RULES 3.
4.
Can replace with _
Can’t start with
number
Day Made Spoiled Each
1 520 12 25
2 100 5 25
3 130 8 25
day1_earned = ?
1 day
made_1 = 520
spoiled_1 = 12
each_cost = 25
day1_earned = ?
1 day
made_1 = 520
spoiled_1 = 12
each_cost = 25
day1_earned = ?
1 day
made_1 = 520
spoiled_1 = 12
each_cost = 25
day1_earned = ?
Find 2 day earned