Search the courses, subjects, tracks, games and features, or jump straight to a page.
5 cards from this section. Quick, good the night before a test.
Print all numbers from 1 to 10 using a for loop.
Use range function starting from 1 to 11.
Use a while loop to count down from 5 to 0.
Start count at 5 and decrement.
What does the 'break' statement do in a loop?
Think about where the loop might stop.
True or False: A while loop will always execute at least once.
Consider how a while loop starts.
Create a program using nested loops to output a triangle pattern of numbers (1 on the first line, 2 on the second, etc. up to 5 lines).
The outer loop controls rows, and the inner loop controls printing spaces.
Write a Python program that prompts for a number and calculates its Fibonacci sequence up to that number using a while loop.
Remember to update your previous numbers in the loop.
7 more questions in this section. Enroll free to practise them all.
Enroll free