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

Lesson Video

18

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 definite count controlled loops in a computer program.

Key Terms

While loop Repeat Until loop Iteration Iterator Counter 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 - Count Controlled Loops Click to see more

Iteration Using definite count loops

There are two major types of loops in Python, for loops and while loops. If you want to repeat a certain number of times (definite count), you will normally use a for loop.

For example, a for loop can be used to print all student records since the computer knows exactly how many students there are.

For Loop Syntax


for variable in range(number):
    indented code goes here...

Using the range function

For loops will iterate through a sequence of numbers using the "range" function. The range function allows you to specify up to three values

range(start value, stop value, step value)

  • The 'start value' is the value the for loop will start at (default value is 0)
  • The 'stop value' is the value the for loop will stop at ( it will never include the stop value so if 5 is used it will stop when it gets to 5 )
  • The 'stop value' is the only value that must always be delcared
  • The 'step value' is the size of the increments for each loop, for example if the step value was 2 then the loop variable(iterator) would increase in value each time by 2 - (default value is 1)

Below is an example of a for loop using the range function with the start value set to stop value set to and the step value set to 1 (it increases by 1 each time).

Task - Recreate the code below and run it to see what it will do

  1. Try and create a loop which will only print out odd numbers
  2. Try and create a loop which will ask the user for a number and do a countdown to 0 from that number.


  • When you are finished screenshot your code into your powerpoint
  • Click here to read more...

    Task 3 - Printing a range Click to see more

    Printing a range of numbers

    You can use the range function in a for loop to print out numbers within a range you decide by setting both the start value and the stop value.

    For example:

  • If we wanted our loop to sequence through the values 3 to 7 one at a time we would make our start value = 3 and our stop value = 8
  • Why 8 and not 7? Well because our range will stop when it gets to the stop value

    Python example:

    Task - Recreate the code below and run it to see what it will do

    1. See if you can print out the range of numbers from 2 to 10
    2. ask the the user to enter two numbers and print out the range between those two numbers

  • When you are finished screenshot your code into your powerpoint

  • Task 4 - Book Task Click to see more

    Task: Iteration

    Open your student workbook at page 18 read through the notes and then complete Tasks 8 & 9 on page 21.


    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 - End of Task Assessment Click to see more