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

Lesson Video

17

Lesson Tasks

  • Watch the Lesson video
    Make notes if needed.
  • Open your Learning Journal
    Complete Task 1 in your Learning Journal
  • Complete the learning activities
    Make sure you complete the book tasks in your Unit Booklet
  • Complete End of Task Assessment
    Update your learning objectives

What do I need to Learn?

0 results forGuest
I need to learn how to understand and know how to use Iteration in a computer program.
I need to learn how to understand and know how to use indefinite condition controlled loops in a computer program.

Key Terms

For loop Iteration Repeat Condition Infinite loop

Task 1 - Getting organised Click to see more


Task: Learning Journal

Open your Learning Journal by clicking on the image below

Good notes will help you organise and process data and information

Task 1: Fill out your learning Journal.

Open your Learning Journal and complete the task below .


Task 2 - Side Task - UsingEdublocks Click to see more

Coding loops

In computer science, a loop is a programming structure that repeats a sequence of instructions until a conditional statement is False. We are going to look at the While loop.

But first...

Click on the link above to open up edublocks



See if you can make the code using the blocks below

Now copy it into into either IDLE or Thonny by clicking on the Blocks button in the top right hand corner of the page.


  • When you are finished screenshot your code into your powerpoint

  • Task 3 - While loop using using Edublocks Click to see more

    Let's try doing a while loop in Edublocks

    See if you can make the code using the blocks below

    Now copy it into into either IDLE or Thonny by clicking on the Blocks button in the top right hand corner of the page.


    Save your file as 'while_loops'


  • When you are finished screenshot your code into your Learning Journal


  • Task 4 - Condition Controlled Loops Click to see more

    Writing a simple while loop in python



    1. Create a New File and Type in the code from the image above
    2. Add in this comment at the top of your code #A while loop allows us to repeat our code

    3. Change the code so that is has an input asking the user if they want to quit. The loop should repeat until the user says yes.

    4. When you are finished screenshot your code into your Learning Journal



    5. Fix the while loop

      1. What is wrong with this loop that tries to count to 10? What happens when it is run? How should it be fixed?

      Fix the code

      Run the code below and see if you can figure out what is being output:

      Task - Rewrite the code above so that it prints out odd numbers from 1 to 21

      There may be several ways for a loop to quit. Using a Boolean variable to trigger the event is a way of handling that. Here's an example:

          
      Looping until the game is over or the user wants to quit"
      
      done = False
      while not done:
          quit = input("Do you want to quit? ")
          if quit == "y":
              done = True
      
          attack = input("Does your elf attack the dragon? ")
          if attack == "y":
              print("Bad choice, you died.")
              done = True
      

      This isn't perfect though, because if the user says she wants to quit, the code will still ask if she wants to attack the dragon. How could you fix this?

      Fix the code below

    6. When you are finished screenshot your code into your Learning Journal



    Task 5 - Lesson Review/Homework 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 have a basic understanding of how with a little help from my teacher
    • I can show my teacher that without their help.
    • 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


    Task 6 - Homework Click to see more


    Complete any unfinished tasks