Structured - Control - Constructs
Structured - Control - Constructs
1
Lesson Learning Outcome
Pass Merit Distinction
2
An Algorithm
3
Characteristics of Algorithms
4
Structured Programming
5
Sequence
PYTHON Code
the script. b = 10 # An integer assignment
total = a + b # Calculating the total
print (“Total = “, total)
6
Selection
7
if without else
a = 10
if a > 10:
print(“Value of a= “,a)
print (“END”)
8
if and else statement
9
Nested if statement
Pseudocode PYTHON Code
Marks = 50
IF Marks > = 80 THEN Marks = 50
Grade = “Distinction” if Marks >= 80:
ELSE IF Mark >= 60 THEN
Grade = ”Distinction”
Grade = “Credit”
elif Marks >= 60:
ELSE IF Mark >= 40 THEN
Grade = ”Credit”
Grade = “Pass”
elif Marks >= 40:
ELSE
Grade = ”Pass”
Grade = “Fail”
END IF else:
END IF Grade = ”Fail”
END IF print(“You got a “,Grade)
Print Grade
10
Desk check this code
Test Case Input marks Expected Result Actual Result Test Passed? Marks = 50
if Marks >= 80:
1 80 Distinction Distinction Yes
Grade = ”Distinction”
2 75 Credit Credit Yes
elif Marks >= 60:
3 59 Pass Pass Yes Grade = ”Credit”
4 60 Credit Credit Yes elif Marks >= 40:
11
Switch statement
Print Color
12
Repetition
13
While loop
Pseudocode PYTHON Code
x= 1
x = 1
Total = 0
Total = 0
WHILE x <= 5
while x <= 5:
Print x
Print (“x = “,x)
Total = Total + x
Total = Total + x
x=x+1
END WHILE x =x + 1
14
For loop
15
Do while loop
16
While loop vs Do while loop
17
Repeat / until loop
Pseudocode PYTHON Code
x=1
REPEAT
Python doesn’t
Print x support repeat until
Total = Total + x loop.
x = x +1
UNTIL x > 5
Print Total
18
Recursion
19
Lesson Summary
20