top of page
top

Python - Section 6 Practice Tasks

noun-loop-6036209-FFFFFF.png

Task One

Using for loops, create a program to output this nursery rhyme: "1, 2, 3, 4, 5, Once I caught a fish alive, 6, 7, 8, 9, 10 then I let it go again".

 

Requirements for full marks:

  • A comment at the start to explain what a for loop is.

  • Two for loops.

Example solution:

py86.PNG

Task Two

Create a program using a while loop that keeps asking a user to enter a number and adds those numbers together to a total. 

 

When the total goes over 100, the program stops and outputs: “OVERLOAD! You have gone over 100!”

​

Requirements for full marks:

  • A comment at the start to explain what a while loop is.

Example solution:

py87.PNG

Task Three

Use a while true loop to let the user enter either A or B.

 

A lets them guess a secret colour. If they get it wrong continue the loop but if they got it correct break the loop.

​

B lets them guess a secret number. Continue if they guess it incorrectly or break if they get it correct.

Example solution:

py68.png
bottom of page