Skip to content
Learnearn.uk » Python Unit Home » Lesson 5 – for loops

Lesson 5 – for loops

Basics Tutorial

Advanced Tutorial

“Challenge


Challenge 17 – Message repeater

For this challenge you need to repeat a message a number of times.

 Bronze

  • Using a for loop, repeat the message ‘Spam!’ 20 times.
  • Use a time.sleep() and os.system(‘clear’) to make the message flash on and off the screen.

 Silver

  • Ask the user to what message they want to print out and print that out 20 times.
  • Ask the user how many times they want to print out the message and repeat it that many times.

 Gold

  • Check that the user has entered a string input for the message at least 5 characters long and repeat the question as necessary.
  • Check that the user has entered a number input for the times and repeat the question if necessary.

Challenge 18

Challenge 18 – Rocket Takeoff

Create a program that prints out a countdown and then prints out blastoff!

 Bronze

  • Your program should count down from 10 to zero, with a 1 second delay between each number
  • Your program should finally say – ‘lift-off!’

 Silver

  • Your program should include an ASCII art rocket.

 Gold

  • Your ASCII art should be loaded from a separate file.
  • Your ASCII art should be animated.

Challenge 19

Challenge 19 – Number printer

 Bronze

  • Your program should print all of the numbers between 1 and 100

 Silver

  • Your program should ask the user to input the 2 numbers(start and end) and print out all the numbers in between.

 Gold

  • Your program should ask the user whether they want to print out all the numbers, just odd numbers, or just even numbers and print out the corresponding numbers.

Challenge 20

Challenge 20 – Lap time recorder

The aim of this challenge is to record race lap times for a racer.

 Bronze

  • write a program that records the time in seconds taken to complete a lap of a race.
  • You program should display the total time taken for the race

 Silver

  • Your program should display the lap number each time round.
  • Your program should program should display the average lap time.

 Gold

  • You program should display the fastest and slowest lap time
  • Your program should check if the user has entered a valid time for a lap. The program should keep asking until a valid time is entered.

 

Animated ASCII Art

Animated ASCII Art video