For Loop in Python

Quiz
•
Computers
•
11th Grade
•
Hard
Nirender Prakash Singh
Used 24+ times
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the syntax of a for loop in Python?
for item in iterable: # code to be executed
for i in range(n): # code to be executed
for element in list: # code to be executed
for item in iterable: # code to be executed
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How do you define the range of a for loop in Python?
By using the range() function with start, stop, and step parameters.
By using the len() function with the iterable as the parameter.
By using the start, stop, and step parameters directly in the for loop.
By using the range() function with only the stop parameter.
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the purpose of the else statement in a for loop?
To specify a block of code to be executed before the loop starts
To specify a block of code to be executed if the loop completes normally
To specify a block of code to be executed if the loop does not complete normally
To specify a block of code to be executed after each iteration of the loop
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How many times does a for loop iterate if the range is (1, 5)?
4
2
1
3
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code?
0 1 2 Loop completed
0 1 2
3
0
1
2
0 1 2
3
Loop completed
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code? for i in range(1, 6, 2): print(i)
1 2 3 4 5
1 2 3 4
1 3 5
1 3 5 7
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code? for i in range(5, 0, -1): print(i)
1
2
3
4
5
1
2
3
4
5
4
3
2
1
4
3
2
1
Create a free account and access millions of resources
Similar Resources on Wayground
10 questions
U5L13 - Pseudocode Homework (Conditionals & Loops)

Quiz
•
10th - 12th Grade
10 questions
Python Loops

Quiz
•
9th - 12th Grade
10 questions
Programming Quiz

Quiz
•
9th - 12th Grade
11 questions
Python Review

Quiz
•
11th Grade
12 questions
CodeHS Unit 1

Quiz
•
9th - 12th Grade
14 questions
For Loops (Java)

Quiz
•
9th - 12th Grade
10 questions
TEST - Trace table exercise 1

Quiz
•
11th Grade
10 questions
Pseudocode - Iteration

Quiz
•
7th - 11th Grade
Popular Resources on Wayground
55 questions
CHS Student Handbook 25-26

Quiz
•
9th Grade
10 questions
Afterschool Activities & Sports

Quiz
•
6th - 8th Grade
15 questions
PRIDE

Quiz
•
6th - 8th Grade
15 questions
Cool Tool:Chromebook

Quiz
•
6th - 8th Grade
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
10 questions
Nouns, nouns, nouns

Quiz
•
3rd Grade
20 questions
Bullying

Quiz
•
7th Grade
18 questions
7SS - 30a - Budgeting

Quiz
•
6th - 8th Grade