Quiz on WHILE Loop in Programming

Quiz on WHILE Loop in Programming

10th Grade

10 Qs

quiz-placeholder

Similar activities

Building Discipline: Why Success is More Than Motivation

Building Discipline: Why Success is More Than Motivation

9th - 12th Grade

10 Qs

Skeletal System Suffix

Skeletal System Suffix

9th - 12th Grade

13 Qs

Feedback Loops

Feedback Loops

10th - 12th Grade

11 Qs

Figure Skating TEST HARD

Figure Skating TEST HARD

6th Grade - Professional Development

10 Qs

Sound Editing

Sound Editing

9th - 11th Grade

10 Qs

youtube

youtube

KG - University

8 Qs

Introduction to Music Technology - year 8

Introduction to Music Technology - year 8

9th Grade - University

15 Qs

Vocabulary Quiz

Vocabulary Quiz

6th Grade - University

10 Qs

Quiz on WHILE Loop in Programming

Quiz on WHILE Loop in Programming

Assessment

Quiz

Other

10th Grade

Hard

Created by

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

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?