Please ensure that JavaScript is running.
Learn
Challenges
Blogs
About
Contact
Learn
Challenges
Blogs
About
Contact
Home
/
Learn
/
Python
/
For Loops
/
Quiz
For Loops
What is the syntax for creating a for loop?
for i in range(5)
print(i)
for i in range(5): print(i)
for (i=0; i<5; i++)
print(i)
for i in range(5):
print(i)
How can you access the index of an element in a list while using a for loop to iterate through it?
By using the index() function
By using the get() function
By using the enumerate() function
It is not possible to access the index of an element in a list while using a for loop
What does the range function do in a for loop?
All answers are correct
It defines the starting point for the loop
It defines the ending point for the loop
It defines the increment or decrement for each iteration of the loop
Can a for loop be used to iterate through a dictionary in Python?
No, a for loop cannot be used to iterate through a dictionary
Yes, using the keys() function
Yes, using the items() function
Yes, using the values() function
How can you exit a for loop early in Python?
By using the continue keyword
By using the break keyword
It is not possible to exit a for loop early in Python
By using the exit() function
Congratulations. You have achieved
/5.
Try Again?