I can use nested selection statements. - Year 8 Computing

Download Report

Transcript I can use nested selection statements. - Year 8 Computing

Do it now activity
Correct the 8 syntax errors:
Age = input(“How old are you?”
If age = 10
Print(You are 10”)
else:
print(“You are not 10”)
Homework
Pseudocode
You will be given a home learning sheet to complete
for homework this term.
Complete challenge 2
Your teacher will explain what you need to do.
Due:
Understand how to use nested if
statements in your programming
1. Use nested if, elif, else
function
2. Correctly identify the flow of
data through a program
By the end of this lesson you will be
able to ....
ALL
(Level 4)
MOST
I know the difference between, and appropriately I can use if and
if, then and else statements.
(Level 5)
I can use a range of operators and expressions e.g. Boolean, and
applies them in the context of program control.
SOME
I can use nested selection statements.
(Level 6)
1.
2.
Use nested if, elif, else function
Correctly identify the flow of data through a program
New Learning
Can you identify who did the crime?
Nested
Selection
statement
If
Else
Elif
Condition
Boolean
Negation
1.
2.
Use nested if, elif, else function
Correctly identify the flow of data through a program
New Learning
Download and investigate the program
called ‘nested selection statements’
from
 www.Y8computing.weebly.com
 Term 4
 Lesson 5
Nested
Selection
statement
If
Else
Elif
Condition
Boolean
Negation
1.
2.
Use nested if, elif, else function
Correctly identify the flow of data through a program
Independent task
Can you adapt the code to:
Check if the user has entered a correct
username and password?
Username = Dsmith Password = teapot
Can you use negation for this?
Nested
Selection
statement
If
Else
Elif
Condition
Boolean
Negation
1.
2.
Use nested if, elif, else function
Correctly identify the flow of data through a program
Independent task
You can use and to check if more than
one statement is true ie
if name == “Dave” and age == 12:
Can you use this in your program?
Nested
Selection
statement
If
Else
Elif
Condition
Boolean
Negation
1.
2.
Use nested if, elif, else function
Correctly identify the flow of data through a program
Copy Keyword
Nesting: When control structures are inserted
within other control structures.
Copy Keyword
Nested
Selection
statement
If
Else
Elif
Condition
Boolean
Negation
1.
2.
Use nested if, elif, else function
Correctly identify the flow of data through a program
Talk task
1. Why did you need to create a nested
selection statement for this task?
2. Why did you need to create an else
statement that was outside of the nesting?
Nested
Selection
statement
If
Else
Elif
Condition
Boolean
Negation
1.
2.
Use nested if, elif, else function
Correctly identify the flow of data through a program
Plenary
Three stars and a wish.
Nested
Selection
statement
If
Else
Elif
Condition
Boolean
Negation
I can ....
ALL
(Level 4)
MOST
Explain the difference between, and appropriately I can use if
and if, then and else statements.
(Level 5)
Use a range of operators and expressions e.g. Boolean, and
applies them in the context of program control.
SOME
Use nested selection statements.
(Level 6)