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

Python - selection

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

Task 1 - Getting Organised - PowerPoint Click to see more

  1. Set your Learning Objectives to red.

  2. Open your PowerPoint from last lesson.

To download the PowerPoint by clicking on the image below



Task 2 - Simple selection - Python Click to see more

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 .
  2. Screenshot or save the link into your PowerPoint
  3. Notice how when we compare if things are equal in python we use == not a single =.


Task 3 - Conditional Statements Click to see more

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.

  • Task 4 - Creating an If Statement Click to see more

    <

    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?

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



    Activity 3

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


    Extension Task

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

    Explain your answers in your Powerpoint next to a screenshot of your code



  • When you are finished don't forget to save your your powerpoint

  • Task 5 - Writing an 'IF ELSE' Statement Click to see more

    Activity 4

    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?


    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

    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?


    Explain your answers in your Powerpoint next to a screenshot of your code



  • When you are finished don't forget to save your your powerpoint

  • Task 6 - Lesson review Click to see more

    Review task:

    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.


    Task 7 - Update Objectives Click to see more

    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.

    🠜 Now update your learning objectivesClick on the Assessment image

    My Notes: coding-p

    Student_Comment_4 not found

    Task Notes/Comments - Add here Click to see more

    Comments/Notes

    Copyright © 2013 -2019 LearnITwithMrC