You are on page 1of 21

PYTHON CHAPTER 2

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

1 day 2 day 3 day

made_1 = 520 made_2 = 100 made_3 = 130

spoiled_1 = 12 spoiled_2 = 5 spoiled_3 = 8

each_cost = 25 day2_earned = ? day3_earned = ?

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

Find 3 day earned

You might also like