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

Using Selection

What am I Learning today?

I am learning how to use selection in my programming (if statements)
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.

If you need to download a copy of thePowerPoint Click here and open Task 1.



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 - 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 code so that is has a user input asking for the number and an else statement in case the number is not greater that 5

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

    Understanding Python's elif Statement

    In Python, the elif statement is used for multiple conditions in a decision-making structure. It stands for "else if," and it comes after an if statement and before an else statement.

    Here is an example of how elif is used:

    if temperature > 30:
        print("It's a hot day.")
    elif temperature > 20:
        print("It's a nice day.")
    elif temperature > 10:
        print("It's a bit cold.")
    else:
        print("It's cold.")
        

    In this example, Python checks each condition in order. If a condition is true, it runs the code inside that block and skips the rest.

    Exercise: Weather Reporter

    Write a Python program using if, elif, and else statements to recommend an outfit based on the temperature.

    • If the temperature is above 25 degrees, recommend wearing shorts and a t-shirt.
    • If the temperature is between 15 and 25 degrees, suggest a long-sleeve shirt and jeans.
    • If the temperature is below 15 degrees, suggest a coat and a warm hat.

    Here's a structure to help you start:

    temperature = # Add a temperature value here
    
    # Write your if, elif, and else statements below
        

    Once you've written your program, test it with different temperatures to see the outfit recommendations.


    Task 6 - Starting Your adventure Click to see more

    Python Text Adventure Task

    Overall objective: In this task, you will use your knowledge of Python's if statement to create your first choices for your text adventure game . "

    Iintroduction example

    You stand at the edge of a dense, ancient forest, its towering trees shrouded in mist that dances in the pale moonlight. The air is thick with the earthy scent of moss and the distant murmur of a hidden stream. Before you lies a forgotten path, overgrown with ivy and covered in fallen leaves, disappearing into the heart of the woods. It beckons you with an eerie allure, promising secrets and treasures untold. But be warned, brave adventurer, for this forest holds mysteries of both wonder and peril. Will you:

    • 1. Venture Deeper: Venture deeper into the forest, following the winding path, driven by curiosity and the promise of adventure?
    • 2. Seek Shelter: Turn back and seek shelter for the night, sensing the dangers lurking within the darkness?
    • 3. Light a Torch: Light a torch and cautiously explore the immediate surroundings, wary of the unknown dangers that may lie nearby?

    Part 2: Creating your Text Adventure in python

    1. Open your Python development environment (e.g., Thonny).
    2. Create a new Python file (e.g., "text_adventure_game.py").
    3. Use Python to implement your captivating introduction into the game by using a print statement. After the introduction, give the player choices that will affect the story's progression.
    4. After your introduction try including variables to store player information (e.g., name, score) and input statements to interact with the player.
    5. Use input to collect the answer to the players choice
    6. Save your Python file. Select "File" > "Save As" from the Thonny menu.
    7. Choose your OneDrive school account as the location to save the file. Navigate to your OneDrive folder and create a new folder if needed. Name the file "MyTextAdventure.py" (note the ".py" extension).
    8. Save the file in your OneDrive folder.
    9. Finally, test your introduction by running your Python program within Thonny. Make sure it welcomes the player, sets the scene, and waits for their response before proceeding to the actual game.

    Tips:

    • For the creative writing part, let your imagination run wild! Experiment with different ideas and themes.
    • For the Python extension, consider using variables to store player-related information and input statements to gather player choices.
    • Read your introduction aloud to ensure it flows smoothly and creates the desired atmosphere.
    • Engage the player's senses by describing sights, sounds, and emotions.
    • Consider the target audience and adjust your writing style accordingly.

    Once you've completed both parts of this task, you will have crafted a captivating introduction and created an interactive text adventure game, showcasing your creative writing skills and your ability to use variables and input in Python.


  • 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 selection in my programming (if statements)

    • I have a basic understanding of how I can use selection in my programming (if statements) with a little help from my teacher
    • I can show my teacher that I can use selection in my programming (if statements) without their help.
    • I can use selection in my programming (if statements) 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-p1

    Student_Comment_3 not found

    Task Notes/Comments - Add here Click to see more

    Comments/Notes

    Copyright © 2013 - 2025 LearnITwithMrC