Search the courses, subjects, tracks, games and features, or jump straight to a page.
3 cards from this section. Quick, good the night before a test.
What is the purpose of loops in programming?
Think about repetitive tasks.
Write a simple for loop to print the numbers 1 to 5.
Use the range function.
What does a for loop do?
Think about the loop structures.
True or False: A while loop will run even if its condition is false at the start.
Consider the condition of the loop.
Create a program that prompts the user to enter numbers and prints their sum. It should stop when the user enters a negative number.
Focus on accumulating the total while checking for the stop condition.
Write a nested loop that prints a multiplication table from 1 to 5.
Think about how to combine loops to achieve the multiplication.
5 more questions in this section. Enroll free to practise them all.
Enroll free