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 will the following code output? for i in range(0, 3): print(i)
Count from the start value up to but not including the stop value.
Write a FOR loop to print 'Hello' 5 times.
How many times do you want to print the message?
What does the range function in a FOR loop do?
Think about what aspect of iteration the range function influences.
True or False: A FOR loop can be used to iterate through a list.
Consider the flexibility of FOR loops.
Write a FOR loop that prints numbers from 20 to 0, decrementing by 2 each time.
Remember how the step value adjusts the direction and increment.
Consider a scenario where you have a list of student scores. Write a FOR loop to print a message for each score, indicating if it is a pass (>= 50) or a fail (< 50).
You're checking a condition for each score; think about how if-else statements work.
6 more questions in this section. Enroll free to practise them all.
Enroll free