Computer Science LearnITWithMrC ⛯ Year 7 Year 8 Year 9 GCSE
Responsive image

Lesson 3 - Selection using IF statements

Overview
Flight Path
Learning Objectives
0 results forGuest
IDSkill_name
 5 I can use selection in my programming (if statements)

🏁 Learning Objective 11 :- I can use selection in my programming (if statements)


Learning selection in Python

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.


Conditional statements

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

Look at the conditional statement in the diamond below, should we DO THIS or DO THAT?

What about this next one, should we DO THIS or DO THAT?

Writing an IF statement

Copy the text below into a Python file and run it to see what happens

Extension Task

Can you change the condition so that it doesn't print anything out at all?


Writing an IF ELSE statement

Copy the text below into a Python file and run it to see what happens

Extension Task

Can you change the condition to check if the two numbers are the same and print out suitable statements?


Writing an ELIF statement

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

Copy the text below into a Python file and run it to see what happens

Extension Task

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?


Update your objectives

control


0 results forGuest
Recent Comments

Teacher Date: 2024-04-18


Guest