Programming foundations
- Chaitra knows how to
+ - * / // % == < >

- Chaitra can rememeber values as long as you are referring with names
Remember 10 as number => number = 10
Add 1 to the number => number = number + 1
Problem: Let solve the problem of area of circle
Hi chaitra
pi = 3.14
radius = 1
result = pi * radius * radius
say result
Problem: Lets solve the problem of simple intrest
- inputs
- principal
- time (in years)
- rate of intrest
- forumla
p * t * r / 100
Hi Chaitra
p = 10000000
t = 5
r = 24
si = p * t * r / 100
say si
Problem: Lets solve the problem of Converting degrees into farnhiet
- Input: celcius
- Formuala:
(C × 9/5) + 32
- Chaitra evaluates operators according to python operator precedence
- Solution:
Hi Chaitra
c = 50
f = (c * (9 / 5)) + 32
Operator Precedence
- This defines the priority

Problem
- Ask chaitra to say number 5 times
number = 5
repeat 5 times and rememeber count in index
say number
number = 5
index = 0
until index < 5
say number
index += 1
- I want Chaitra to calculate gst on popcorn
popcorn = caramel
price = 1000
if popcorn == normal
tax = price * 5 / 100
if popcorn == salted
tax = price * 12 / 100
if popcorn == caramel
tax = price * 18 / 100
total = price + tax
say total
Factorial of a number
Hi Chaitra
number = 5
index = 1
factorial = 1
until index <= number
factorial = factorial * index
index = index + 1
say factorial
Project euler 1
Hi chaitra
index = 1
result = 0
number = 10
until index < number
is_multiple = (index % 3 == 0) or (index % 5 == 0)
if is_multiple == True
result = result + index
index = index + 1
say result
Project euler 2
- Lets solve fibonnaci sequence
a = 1
b = 2
say a
say b
max = 30
until (a + b) <= max
c = a + b
say c
a = b
b = c
Like this:
Like Loading...