
control statements
Quiz
•
Computers
•
University
•
Practice Problem
•
Hard
thanga_palani_ thanga_palani_
FREE Resource
Enhance your content in a minute
13 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What does the break statement do in a loop?
Restarts the loop
Skips the current step
Exits the loop completely
Makes the loop run forever
Answer explanation
The break statement is used in loops to exit the loop completely, terminating its execution. This means that when a break is encountered, the loop stops running, and control is transferred to the statement following the loop.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What does the continue statement do?
Ends the loop
Skips the rest of the loop and moves to next iteration
Skips the rest of the loop and moves to next iteration
Skips input
Answer explanation
The continue statement skips the rest of the current loop iteration and proceeds to the next iteration. This means any code after the continue statement within the loop will not execute for that iteration.
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will this code output?
for i in range(5):
if i == 3:
break
print(i)
0 1 2
0 1 2 3 4
1 2 3
0 1 2 3
Answer explanation
The loop iterates from 0 to 4. When i is 3, the 'break' statement exits the loop. Thus, only 0, 1, and 2 are printed before the loop is terminated. Therefore, the output is '0 1 2', making it the correct choice.
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output?
for i in range(5):
if i == 3:
continue
print(i)
0 1 2 3 4
1 2 3
0 1 2 4
0 1 2
Answer explanation
The loop iterates from 0 to 4. When i is 3, the 'continue' statement skips the print. Thus, the output is 0, 1, 2, and 4, making the correct answer '0 1 2 4'.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
In a while loop, where is break used?
Inside a condition
Inside the loop block
Outside the loop
After loop ends
Answer explanation
The 'break' statement is used inside the loop block to exit the loop prematurely when a specific condition is met. This allows for more control over the loop's execution, making 'Inside the loop block' the correct choice.
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What happens if break is not used?
Loop stops
Loop continues normally
Syntax error
System shuts down
Answer explanation
If 'break' is not used in a loop, the loop continues normally, executing all iterations until its condition is no longer met. This means the loop will run to completion unless interrupted by other means.
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What does this print?
i = 0 while i < 5:
i += 1
if i == 3:
continue
print(i)
1 2 3 4 5
1 2 4 5
1 2 3 5
0 1 2 3
Answer explanation
The loop increments i from 0 to 5. When i equals 3, the 'continue' statement skips the print, so 3 is not printed. The output is 1, 2, 4, and 5, making '1 2 4 5' the correct answer.
Create a free account and access millions of resources
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
10 questions
1 Herramientas Digitales
Quiz
•
6th Grade - University
10 questions
System Analysis & Design
Quiz
•
University
10 questions
Visual Basic 2010
Quiz
•
8th Grade - University
10 questions
Ulangan Harian Teknologi WAN Kelas XI Semester Gasal
Quiz
•
University
11 questions
Types of Mass Media
Quiz
•
10th Grade - Professi...
15 questions
[CEH4H3] Sistem Tertanam Ganjil 1819 Kuis Online 2
Quiz
•
University
15 questions
Introducción Redes Tele1 IB
Quiz
•
10th Grade - University
10 questions
Software dan Hardware
Quiz
•
University
Popular Resources on Wayground
10 questions
Forest Self-Management
Lesson
•
1st - 5th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
30 questions
Thanksgiving Trivia
Quiz
•
9th - 12th Grade
30 questions
Thanksgiving Trivia
Quiz
•
6th Grade
11 questions
Would You Rather - Thanksgiving
Lesson
•
KG - 12th Grade
48 questions
The Eagle Way
Quiz
•
6th Grade
10 questions
Identifying equations
Quiz
•
KG - University
10 questions
Thanksgiving
Lesson
•
5th - 7th Grade
Discover more resources for Computers
10 questions
Identifying equations
Quiz
•
KG - University
7 questions
Different Types of Energy
Interactive video
•
4th Grade - University
20 questions
HS2C2 AB QUIZIZZ
Quiz
•
1st Grade - Professio...
14 questions
Homonyms Quiz
Quiz
•
KG - University
16 questions
Parts of a Parabola
Quiz
•
8th Grade - University
10 questions
A Brief History of Geologic Time
Interactive video
•
11th Grade - University
15 questions
Black Friday/Cyber Monday
Quiz
•
9th Grade - University
7 questions
Biomolecules (Updated)
Interactive video
•
11th Grade - University
