
Quiz on WHILE Loop in Programming

Quiz
•
Other
•
10th Grade
•
Hard
Nguyễn Trang
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the purpose of the `while` statement in programming?
Execute a block of code only once
Repeat a block of code a specified number of times
Repeat a block of code while the condition is true
Terminate the program
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the syntax of the `while` loop in Python?
while (condition) { statements }
while: condition { statements }
while condition:
while = condition:
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
When does the `while` loop terminate?
When memory runs out
When the condition is false
When the user inputs 0
When the program crashes
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What does the following code do? x = 1; while x < 5: print(x); x += 1
Prints numbers from 0 to 5
Prints numbers from 1 to 4
Prints numbers from 1 to 5
Infinite loop
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Why is it necessary to increment the variable `x` in the `while` loop?
To slow down the program
To avoid infinite looping
To print a character
To check syntax
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
If the initial condition is `False` when using `while`, then:
The loop will not execute at all
The loop will still execute once
A syntax error occurs
The computer freezes
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Choose the correct code to calculate the sum from 1 to 5:
sum = 0; i = 1; while i < 6: sum += i; i += 1
sum = 0; i = 1; while i <= 5: i += 1; sum += i
sum = 0; i = 1; while i <= 5: sum += i
sum = 0; i = 1; while i <= 5: sum += i; i += 1
Create a free account and access millions of resources
Similar Resources on Wayground
10 questions
Introduction to Setting Financial Goals Quiz

Quiz
•
9th - 12th Grade
12 questions
Ch. 20 Chemical Textur Services

Quiz
•
10th - 12th Grade
13 questions
6.3 B: Contraction of a Skeletal Muscle as a Whole

Quiz
•
10th - 12th Grade
10 questions
Life Insurance Quiz

Quiz
•
9th - 12th Grade
10 questions
Level 1 Qtrly Practice Quiz Jan 25

Quiz
•
10th Grade
10 questions
The Second Conditional

Quiz
•
3rd - 12th Grade
15 questions
Introduction to Java Programming

Quiz
•
9th - 12th Grade
13 questions
Summer School Physical Science - CH 8 - Section III Quiz

Quiz
•
9th - 11th Grade
Popular Resources on Wayground
10 questions
Lab Safety Procedures and Guidelines

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

Quiz
•
3rd Grade
10 questions
9/11 Experience and Reflections

Interactive video
•
10th - 12th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
11 questions
All about me

Quiz
•
Professional Development
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
9 questions
Tips & Tricks

Lesson
•
6th - 8th Grade
Discover more resources for Other
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
10 questions
9/11 Experience and Reflections

Interactive video
•
10th - 12th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
20 questions
Getting to know YOU icebreaker activity!

Quiz
•
6th - 12th Grade
10 questions
Impact of 9/11 and the War on Terror

Interactive video
•
10th - 12th Grade
21 questions
Lab Safety

Quiz
•
10th Grade
28 questions
Ser vs estar

Quiz
•
9th - 12th Grade
6 questions
Biography

Quiz
•
4th - 12th Grade