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

Python - selection

What am I Learning today?

I am learning how to use two way selection in my programming (if, then, else)
I am learning 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


If for any reason you cannot open Thonny then click on the link below to use an online version of Python called CodeSkulptor3. Just be aware that the lessons are based upon using python in Thonny however the code will be exactly the same.


Task 2 - Getting Organised - Python Click to see more

Choose your Python

  • You have two python options for completing todays lesson.

  • Option 1

    Thonny

    In class we are going to be using the Python tool called 'Thonny' This is an app on your computer so search for it in the search bar

    Option 2

    CodeSkulptor3

    If for any reason you cannot open Thonny then click on the link below to use an online version of Python called CodeSkulptor3. Just be aware that the lessons are based upon using python in Thonny however the code will be exactly the same.


    Task 3 - 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 4 - Using Input Click to see more

    User Input

    Last week we learned that In python if you want the user to input data into the program, you can use the input()function, this is another built in functions to help us put data into our program.

    ...In order to get user input in python you need to use the input() function. This puts a prompt onto the screen to allow the user to enter data. If you want to use the data in your program you have to store it in a variable . The print function can then use the variable to output our user input to the screen .



    Let's change the code from the previous task and rather than write Weather = "Raining" instead use an input() to get the weather from the user.

  • Here is the code from the previous task:
    1. Change the code above so it uses an input to get the input() to get the weather from the user.

    2. Save the file name as 'selection2'.

    3. Run the code.

    4. Remember to use correct 'Indentation'


    Task 5 - Using Numbers 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


    1. Can you add input() to get the user to enter a number
    2. Can you add an else to your code and print out The number is small

    Don't forget to turn the user input() into an integer using the int() function.

    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 - Using 'elif' Click to see more

    Activity 3 - part answer

    The text below shows how to add in an else for the previous activity.

  • Have you added in an input() statement?
  • have you turned the user input() into an integer using the int() function?

  • 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?

    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 7 - 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 8 - 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 - 2026 LearnITwithMrC