02 if Statements
02 if Statements
Computer Science
INPUT num
What is
this flow Yes num > No
diagram 10?
Stop
INPUT num1
• Flow diagrams show the
different routes a user
may take through a INPUT num2
program.
answer = num1 + num2
• So far all our programs
have been sequential
and each line would be OUTPUT answer
run, one after the other.
Stop
© Nichola Wilkin Ltd 2019
www.nicholawilkin.com
4
Flow diagrams Start
INPUT num1
There are a variety of
different symbols used:
INPUT num2
= Terminator
answer = num1 + num2
= Input or output
OUTPUT answer
= Process
(doing something)
Stop
© Nichola Wilkin Ltd 2019
www.nicholawilkin.com
5
Flow diagrams Start
INPUT num1
OUTPUT answer
Stop
© Nichola Wilkin Ltd 2019
www.nicholawilkin.com
6
Flow diagram Start
INPUT num2
OUTPUT answer
Stop
© Nichola Wilkin Ltd 2019
www.nicholawilkin.com
7
Draw the flow diagram
for this Python program:
Input or
Terminator Process
Output
© Nichola Wilkin Ltd 2019
www.nicholawilkin.com
8
Answer Start
INPUT name
INPUT num
OUTPUT answer
Stop
Stop
© Nichola Wilkin Ltd 2019
www.nicholawilkin.com
12
Decision diamond
Yes num > No
10?
OUTPUT OUTPUT “Not
“Over 10” over 10”
• A decision diamond has one input and two
possible outputs.
• It allows the program to take a different
route, depending on if it meets the criteria (in
this case if num is greater than 10).
© Nichola Wilkin Ltd 2019
www.nicholawilkin.com
13
© Nichola Wilkin Ltd 2019
www.nicholawilkin.com
14
How much do
you remember?
Create these
programs to
recap what
you have
learnt.
Create these
programs to
recap what
you have
learnt.
INPUT num2
Create the Python
program for this answer = num1 + num2
flow diagram.
Yes answer No
> 10?
Now work together
as a class, to tell newAnswer = answer + 3 newAnswer = answer * 2
the teacher what
to type in to
OUTPUT newAnswer
create the same
program.
© Nichola Wilkin Ltd 2019 Stop 19
www.nicholawilkin.com