Conditional flow
-
Generally program executes instructions one by one
-
What kid knows
- Addition (+)
- Subtraction (-)
- Multiplication (*)
- integer Division
- Quotient (//)
- Remainder or modulus (%)
- Division (/)
- equals (==)
- less than (
<) - less than or equals
<= - gt (
>) - ge (‘>=)
- assignment (
=)
Scenario – 1
- we need to make this kid tell if the number is even or odd
- solution
number = 101
reminder = number % 2
if reminder == 0
say even
else
say odd
Scenario – 2
-
We need to make this kid tell if person is Underweight, Healthy Weight, Overweight, Obesity by looking at bmi

-
Solution
#BMI = weight (kg) / [height (in) × 0.0254]²
weight = 75
height = 70
bmi = weight / ((height * 0.0254) * (height * 0.0254))
if 0 < bmi <= 18.5
say under weight
else if 18.5 < bmi <= 25
say healthy weight
else if 25 < bmi <= 30
say overweight
else
say obesity
Exercise
- Take length and breadth and find if it is square or rectangle.
- Right angled triangle or not
