Log in
Sign up for FREE
arrow_back
Library

Exit Ticket For loop

star
star
star
star
star
Last updated over 2 years ago
8 questions
1
1
1
1
1
1
1
1
Question 1
1.

Question 2
2.

Question 3
3.

Question 4
4.

Question 5
5.

What does the 'range' function do in a Python 'for' loop?

Question 6
6.

What is the starting index when using a 'for' loop with the 'range' function in Python?

Question 7
7.

How would you write a for loop in Python to iterate from 1 to 5?

Question 8
8.

What is the Python for loop structure to print the numbers 3, 4 and 5?

What does a for loop do in Python?
It exits the program
It runs an infinite loop
It executes a block of code a certain number of times.
It executes a code once
What is the output when you execute: `for i in range(5): print(i)` in Python?
1 2 3 4 5
0 1 2 3
0 1 2 3 4
5 4 3 2 1 0
Given the for loop `for i in range(2,10,2): print(i)`, what is the output?
2 4 6 8
2 4 6 8 10
2 3 4 5 6 7 8 9
2
How would you initialize a for loop to iterate over a list ['apple', 'banana', 'cherry'] in Python?
for i in ['apple', 'banana', 'cherry']:
for i in range(['apple', 'banana', 'cherry']):
for ['apple', 'banana', 'cherry'] in i:
for i < ['apple', 'banana', 'cherry'].length: