Quiz on WHILE Loop in Programming

Quiz on WHILE Loop in Programming

10th Grade

10 Qs

quiz-placeholder

Similar activities

Dr. Vikram Sarabhai

Dr. Vikram Sarabhai

6th Grade - University

10 Qs

Econ-Lesson 2.3 Quiz

Econ-Lesson 2.3 Quiz

9th - 12th Grade

10 Qs

ANIME!!

ANIME!!

5th Grade - Professional Development

10 Qs

Guess the blackpink song lyrics

Guess the blackpink song lyrics

4th Grade - Professional Development

10 Qs

CFC Promotion Quiz

CFC Promotion Quiz

5th - 12th Grade

15 Qs

Św. Abraham

Św. Abraham

1st - 12th Grade

11 Qs

QUIZ ON INDEPENDANCEDAY

QUIZ ON INDEPENDANCEDAY

KG - University

15 Qs

Biodiversity.

Biodiversity.

9th - 12th Grade

12 Qs

Quiz on WHILE Loop in Programming

Quiz on WHILE Loop in Programming

Assessment

Quiz

Other

10th Grade

Practice Problem

Hard

Created by

Nguyễn Trang

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

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

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?