NEW
Font size
WorksheetsWeekly Contest #11
Total questions: 10
Worksheet time: 5mins
Which statement is used to exit a loop prematurely?
return
break
exit
close
Which of the following is true about the "do-while" loop?
It is similar to the "while" loop
It does not support a loop condition
The loop body is executed at least once
It can only be used for counting
................. can only test for equality, where as ....................... can evaluate any type of the Boolean expression.
switch, if
if, switch
if, break
continue, if
What is the purpose of the "elif" statement in Python?
To handle exceptions
To create a loop
To define a function
To check additional conditions after the initial if statement
What is the output of the following code snippet?
for i in range(5):
if i == 3:
continue
print(i)
0 1 2 3 4
0 1 2
0 1 2 3
0 1 2 4
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)
[3, 6, 9, 12, 15]
[1, 2, 3, 4, 5]
[1, 3, 9, 16, 25]
[3, 4, 5, 6, 7]
What is the purpose of the del statement?
Deletes a file from the filesystem
Removes an element from a list by value
Removes an attribute from an object
Exits the program
What is the output of this code?
1 3 5 7 9
1 2 3 4 5
2 4 6 8 10
2 4 6 8
What is the purpose of the else clause in a Python if-else statement?
It is used to handle exceptions.
It is executed when the if condition is true.
It is executed when none of the preceding if or elif conditions are true.
It is used to terminate the program.
Correct syntax of writing Simple if' statement is
if condition
statements
if (condition)
statements
if condition --
statements
if condition :
statements
