
Unit 9 Key programming concepts T2 Sequence & selection
Presentation
•
Computers
•
10th Grade
•
Practice Problem
•
Hard
Michael Harrington
FREE Resource
17 Slides • 13 Questions
1
Unit 9 Topic 2
Unit 9 Topic 2
2
Unit 9 Topic 2
Unit 9 Topic 2
Objectives
• Use selection and nested selection statements
• IF statements
• CASE statements
• Use NOT, AND and OR when creating
Boolean expressions
• Use of logical operators including:
• =
• <
• <=
• >
• >=
• <>
3
Fill in the Blanks
4
Fill in the Blanks
5
Fill in the Blanks
6
Unit 9 Topic 2
Unit 9 Topic 2
Sequence and selection
Unit 9 Key programming concepts
Starter
• Control structures choose the direction which a
program will take based on the values of variables
• What are the three
basic control
structures used
in programming?
• What are three
operators used
in Boolean
expressions?
7
Unit 9 Topic 2
Unit 9 Topic 2
Sequence and selection
Unit 9 Key programming concepts
Starter
• What are the three basic control structures used
in programming?
• Sequence, selection and iteration
• What are three operators used in
Boolean expressions?
• AND, OR, NOT
8
Unit 9 Topic 2
Unit 9 Topic 2
Sequence and selection
Unit 9 Key programming concepts
Sequence
• The statements are executed
one by one in the order they
are written:
mark1 <- 78
mark2 <- 67
total <- mark1 + mark2
average <- total / 2
OUTPUT average
9
Unit 9 Topic 2
Unit 9 Topic 2
Sequence and selection
Unit 9 Key programming concepts
Selection
• An IF statement is a selectionstatement
• The next statement to be executed depends on
whether the condition being tested is True or False
IF average >= 80
THEN
OUTPUT "Distinction"
ELSE
OUTPUT "Pass"
ENDIF
10
Unit 9 Topic 2
Unit 9 Topic 2
Sequence and selection
Unit 9 Key programming concepts
Comparison expressions
• The condition average >= 80is a
Boolean expression
• The outcome will always evaluate to TRUE or FALSE
• Comparison operators include
=
equal to
<>
not equal to
>
greater than
<
less than
• What are two other comparison operators?
• Why do you need to be careful with = in real
programming languages?
11
Multiple Select
What are the three basic control structures used in programming?
AND
iteration
NOT
Sequence
selection
12
Multiple Select
What are three operators used in Boolean expressions?
AND
OR
NOT
Sequence
selection
13
Unit 9 Topic 2
Unit 9 Topic 2
Sequence and selection
Unit 9 Key programming concepts
Boolean expressions
• Here is a full list of comparison operators
•
• A single = is often used for assignment - e.g. age = 14
Comparison
operators
Meaning
Pseudocode
example
Result
Notes
=
Equal to
5 = 5
True
Many languages
use a double ==
<>
Not equal to
5 <> 5
False
Many languages
use !=
>
Greater than
5 > 5
False
>=
Greater than or equal
to
5 >= 5
True
<
Less than
5 < 5
False
<=
Less than or equal to
5 <= 5
True
14
Match
Match the following
<=
<
>=
<>
>
Less than or equal to
Less than
Greater than or equal to
Not equal to
Greater than
Less than or equal to
Less than
Greater than or equal to
Not equal to
Greater than
15
Unit 9 Topic 2
Unit 9 Topic 2
Sequence and selection
Unit 9 Key programming concepts
If statements
• If statements allow different branches to be executed
based on the result of a Boolean expression
IF average >= 60
THEN
OUTPUT "Pass"
ELSE
OUTPUT "Fail"
ENDIF
16
Unit 9 Topic 2
Unit 9 Topic 2
Sequence and selection
Unit 9 Key programming concepts
Nested if statements
• If statements may be nested:
IF member = "child"
THEN
IF day = "Saturday"
THEN
swimPrice ← 2.00
ELSE
swimPrice ← 2.50
ENDIF
ELSE
swimPrice ← 4.00
ENDIF
• What is the price for an adult on Saturday?
•What is the price for a child on Sunday?
17
Multiple Choice
What is the price for an adult on Saturday?
2.00
4.00
2.50
0
18
Multiple Choice
What is the price for a child on Sunday?
2.00
4.00
2.50
0
19
Multiple Choice
What is the price for Mr H on Saturday ?
2.00
4.00
2.50
0
20
Unit 9 Topic 2
Unit 9 Topic 2
Sequence and selection
Unit 9 Key programming concepts
Complex Boolean expressions
• Boolean expressions can include the Boolean
operators AND, OR and NOT
• For example:
IF (mark < 0) OR (mark > 100) THEN …
Operator
Description
AND
Returns TRUE if both conditions are TRUE
OR
Returns TRUE if either of the conditions are TRUE
NOT
A TRUE expression becomes FALSE and vice versa
21
Unit 9 Topic 2
Unit 9 Topic 2
Sequence and selection
Unit 9 Key programming concepts
True or False?
• Complete the table:
Mark1
Mark2
Condition
True or
False?
80
67
(mark1 >= 80) AND (mark2 >= 80)
82
80
(mark1 >= 80) OR (mark2 >= 80)
35
(mark1 > 30) OR (mark1 < 50)
65
(mark1 < 30) OR (mark1 > 80)
0
75
NOT(mark1 > 50) AND (mark2 > 50)
65
85
NOT(mark1 < 60) AND NOT (mark2 < 80)
Which one is the misconception?
Lots of beginners make this mistake!
22
Unit 9 Topic 2
Unit 9 Topic 2
Sequence and selection
Unit 9 Key programming concepts
True or False?
Mark1
Mark2
Condition
True or
False?
80
67
(mark1 >= 80) AND (mark2 >= 80)
False
82
80
(mark1 >= 80) OR (mark2 >= 80)
True
35
(mark1 > 30) OR (mark1 < 50)
True
65
(mark1 < 30) OR (mark1 > 80)
False
0
75
NOT(mark1 > 50) AND (mark2 > 50)
True
65
85
NOT(mark1 < 60) AND NOT (mark2 < 80)
True
• Complete the table:
23
Multiple Select
If x = 3 and y = 5, choose all the statements that evaluate to True.
x < y
y > -9
2 * x == y
y MOD x == 3
(MOD finds the remainder)
24
Multiple Choice
Evaluate:
2 < 3 And ( Not 3 > 2)
True
False
25
Unit 9 Topic 2
Unit 9 Topic 2
Sequence and selection
Unit 9 Key programming concepts
CASE statements
• Writing out lots of IF statements can be tedious
• CASE statements will branch depending on many different
possible values for an identifier
INPUT KeyPress
CASE OF KeyPress
"1" : showMenu()
"2" : showInstructions()
"3" : playGame()
"Q" : quitGame()
OTHERWISE OUTPUT "Not a valid option"
ENDCASE
26
Unit 9 Topic 2
Unit 9 Topic 2
Sequence and selection
Unit 9 Key programming concepts
CASE statements
• CASE statements are not available in some
programming languages such as Python
• A drawing program lets the user move the pen
position when the following keys are pressed:
• W subtracts 1 from the variable Y Position
• S adds 1 to the variable Y Position
• A subtracts 1 from the variable Xposition
• D adds 1 to the variable Xposition
• Create pseudocode using CASE statements to carry
out the above
27
Labelling
A drawing program lets the user move the pen position when the following keys are pressed:
W subtracts 1 from the variable Y Position
S adds 1 to the variable Y Position
A subtracts 1 from the variable X position
D adds 1 to the variable X position
other
"X"
"A"
"D"
"W"
"S"
"Y"
Y
28
Unit 9 Topic 2
Unit 9 Topic 2
Sequence and selection
Unit 9 Key programming concepts
Plenary
• Look at the following code:
hourlyRate <- 15.50
INPUT hoursWorkedInWeek
IF hoursWorkedInWeek > 168
THEN
OUTPUT "That’s impossible"
ELSE
totalPay <- hoursWorkedInWeek * hourlyRate
OUTPUT totalPay
ENDIF
• With a partner, identify each of the following:
• A comparison operator, a Boolean expression a selection
structure, a sequence, three assignment operators, an output
statement, one mathematical operator
29
Labelling
identify each of the following:
A comparison operator,
a Boolean expression
a selection structure,
a sequence,
three assignment operators,
an output statement,
one mathematical operator
Assign Op
Math Op
Output
Boolean
Comparison
30
Unit 9 Topic 2
Unit 9 Topic 2
Sequence and selection
Unit 9 Key programming concepts
Worksheet 2
• Now complete Task 1,2 & 3 on Worksheet 2
Unit 9 Topic 2
Unit 9 Topic 2
Show answer
Auto Play
Slide 1 / 30
SLIDE
Similar Resources on Wayground
24 questions
Jaringan Komputer dan Internet
Presentation
•
10th Grade
20 questions
Trig Ratios Review
Presentation
•
10th Grade
21 questions
Web Design
Presentation
•
10th - 11th Grade
22 questions
Bahasa Inggris
Presentation
•
10th Grade
22 questions
DNA/RNA Mutations
Presentation
•
10th Grade
22 questions
DNA and RNA Review
Presentation
•
10th Grade
24 questions
2Q-Module 1 Lesson 7: System Unit Disassembly
Presentation
•
10th Grade
21 questions
Intro to mole
Presentation
•
10th Grade
Popular Resources on Wayground
16 questions
Grade 3 Simulation Assessment 2
Quiz
•
3rd Grade
19 questions
HCS Grade 5 Simulation Assessment_1 2526sy
Quiz
•
5th Grade
10 questions
Cinco de Mayo Trivia Questions
Interactive video
•
3rd - 5th Grade
17 questions
HCS Grade 4 Simulation Assessment_2 2526sy
Quiz
•
4th Grade
24 questions
HCS Grade 5 Simulation Assessment_2 2526sy
Quiz
•
5th Grade
13 questions
Cinco de mayo
Interactive video
•
6th - 8th Grade
20 questions
Math Review
Quiz
•
3rd Grade
30 questions
GVMS House Trivia 2026
Quiz
•
6th - 8th Grade