wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Weekly Contest #11

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

Which statement is used to exit a loop prematurely?

a)

return

b)

break

c)

exit

d)

close

2.

Which of the following is true about the "do-while" loop?

a)

It is similar to the "while" loop

b)

It does not support a loop condition

c)

The loop body is executed at least once

d)

It can only be used for counting

3.

................. can only test for equality, where as ....................... can evaluate any type of the Boolean expression.

a)

switch, if

b)

if, switch

c)

if, break

d)

continue, if

4.

What is the purpose of the "elif" statement in Python?

a)
  • To handle exceptions

b)

To create a loop

c)

To define a function

d)

To check additional conditions after the initial if statement

5.

What is the output of the following code snippet?

for i in range(5):
   if i == 3:
       continue
   print(i)

a)

0 1 2 3 4

b)

0 1 2

c)

0 1 2 3

d)

0 1 2 4

6.

What is the output of the following code snippet?

def function(x):
   return x * 3

numbers = [1, 2, 3, 4, 5]
result = list(map(lambda num: function(num), numbers))
print(result)

a)

[3, 6, 9, 12, 15]

b)

[1, 2, 3, 4, 5]

c)

[1, 3, 9, 16, 25]

d)

[3, 4, 5, 6, 7]

7.

What is the purpose of the del statement?

a)
  • Deletes a file from the filesystem

b)

Removes an element from a list by value

c)

Removes an attribute from an object

d)

Exits the program

8.

What is the output of this code?

a)

1 3 5 7 9

b)

1 2 3 4 5

c)

2 4 6 8 10

d)

2 4 6 8

9.

What is the purpose of the else clause in a Python if-else statement?

a)

It is used to handle exceptions.

b)

It is executed when the if condition is true.

c)

It is executed when none of the preceding if or elif conditions are true.

d)

It is used to terminate the program.

10.

Correct syntax of writing Simple if' statement is

a)

if condition

statements

b)

if (condition)

statements

c)

if condition --

statements

d)

if condition :

statements