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.
Write a for loop to print numbers 0 to 4.
Use the range function for your loop.
Write a while loop to print 'Hello' three times.
Initialize a counter and condition before the loop.
What type of loop should be used when the number of iterations is known?
Think about how you would iterate over a list or range.
True or False: A while loop will run forever if the condition is always true.
Remember to consider the condition of the loop.
Write a program that generates the Fibonacci sequence up to 100 using both for and while loops.
Remember the Fibonacci sequence starts with 0 and 1.
Create a program that accepts user input to keep track of all the numbers entered until a negative number is inputted, then displays the total count and average.
You'll need both a count and a total to compute the average at the end.
5 more questions in this section. Enroll free to practise them all.
Enroll free