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.
Write a for loop to print all numbers from 1 to 5.
Use range from 1 to 6 to include 1 to 5.
Create a for loop that prints characters from a string 'hello'.
You can use the string directly as the sequence.
What is the output of the following code?
for i in range(3):
print(i)Consider the starting point and how many numbers are produced by range.
True or False: The for loop can iterate only through lists.
Recall other sequences that can be iterated.
Create a program that uses a for loop to find the factorial of numbers from 1 to 5.
Remember that factorial is the product of all positive integers up to that number.
Construct a for loop that generates the Fibonacci sequence up to 100.
Keep track of the last two Fibonacci numbers and update them in each iteration.
4 more questions in this section. Enroll free to practise them all.
Enroll free