Search the courses, subjects, tracks, games and features, or jump straight to a page.
4 cards from this section. Quick, good the night before a test.
What will the following code output? for i in range(3): print(i)
Think about the range function and how it defines the loop iterations.
Write a simple for loop to print numbers from 1 to 10.
Use the range function to set the range of numbers.
What does a 'for' loop do?
Focus on its defined iterations.
True or False: A while loop can run indefinitely.
What happens if you forget to change the condition?
Write a program using a while loop that prints the Fibonacci series up to 10 terms.
Keep track of the last two numbers to form the next one.
Design a loop that counts down from 10 to 1, printing 'Blast off!' after the countdown.
Consider how to set up your counting backwards.
5 more questions in this section. Enroll free to practise them all.
Enroll free