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 loop output?
for i in range(3):
print(i)Think about how many times the loop will execute.
What is the purpose of a while loop?
Consider how you would use it in a real-life scenario.
What is a for loop used for?
Think about how we can count iterations in programming.
True or False: The 'continue' statement causes a loop to stop execution entirely.
Consider what happens to the loop's progression with 'continue'.
Write a program that takes a number from the user and sums all integers from 1 to that number using a while loop.
Prompt the user for input and keep track of the total.
Create a number guessing game that gives the user three attempts to guess a randomly generated number between 1 and 10. Use a while loop.
Utilize random number generation and keep count of attempts.
5 more questions in this section. Enroll free to practise them all.
Enroll free