Computer Science LearnITWithMrC ⛯ Year 7 Year 8 Year 9 GCSE ## What do I need to Learn?

 I need to learn how to use two way selection in my programming (if, then, else) I need to learn how to use both sequencing and selection to solve a problem

## Knowledge Organiser  ## Lesson  1. Set your Learning Objectives to red.

2. Open your PowerPoint from last lesson.   In Python The 'if' statement is used to conditionally execute a statement. In other words we look at a statement(conditional) and decide if that conditional statement is true or false,we then do one thing when the condition is true and something else when the condition is false.   Lets see if we can create a version of the above flowchart in python. ### Activity 1

1. Copy the code above, then Run it to see what happens .
3. Notice how when we compare if things are equal in python we use == not a single =.  In python when we compare two or more data values or identifiers we have to use comparison operators.

These are mathmatical symbols like ==, >=, < etc.

This allows us to determine if the comparison we are making is True or False

For example:

• If 8 >= 7 would be True

• If 7 >= 8 would be False

These are called conditional statements in python because they determine if a condtion is True or False.

A conditional statement is any statement that can be determined to be True or False. To make a statement conditional we use comparison operators ### Activity 2

Complete the code below you can find a link to it on codeskulptor by

clicking here • Don't forget to save your code and then screenshot it into your PowerPoint.

•  <

We use conditional statements in a python if statement.

• If the condition is True then we do something
• else we do something else.

Look at the conditional statement in the diamond below, should we DO THIS or DO THAT?   ### Activity 3 Copy the text below into a Python file and run it to see what happens Can you change the conditional operator so that it doesn't print anything out at all? • When you are finished don't forget to save your your powerpoint
•   ### Activity 4 Copy the text below into a Python file and run it to see what happens Can you change the condition to check if the two numbers are the same and print out suitable statements?

Sometimes we want to have more that two opions when we make a choice we can do that in python by using an elif statement.

### Activity 5 Copy the text below into a Python file and run it to see what happens 1. Can you change the code so that the user inputs a number and you then print out whether it is small medium big or huge?

2. Can you develop the code so that the user can input their favourite colour and you then print out something about the colour they chose? • When you are finished don't forget to save your your powerpoint
•   Tick each task when you have successfully done it in the following list: Create a conditional statement in a simple if statement.
Create an if else statememnt so that it prints out something if the conditional statement is either true or False.
Create an if elif else statement for a quiz type multiple choice question.  ### Summing it all up

Lets look at the learning outcomes and decide which one best describes our current level of understanding :

Tick the one you feel is closest to your level

## Learning Outcomes I need to learn how to use two way selection in my programming (if, then, else)

• I have a basic understanding of how I can use two way selection in my programming (if, then, else) with a little help from my teacher
• I can show my teacher that I can use two way selection in my programming (if, then, else) without their help.
• I can use two way selection in my programming (if, then, else) independently and I can also explain it to others and can complete any extension tasks I am given.

## My Notes: coding-p  