NEW
Font size
WorksheetsCode Sprint '25
Total questions: 20
Worksheet time: 15mins
What will be the output of the following code?
for i in range (3):
print(i)
0 1 2
What will be the output of the following code?
for j in range(5):
print(j * 2)
0 2 4 6 8
0 1 2 3 4
1 3 5 7 9
2 4 6 8 10
What will be the output of the following code?
for k in range(2, 5):
print(k ** 2)
2 3 4
2 3 4
4 9 16
1 4 9
What will be the output of the following code?
for m in range(1, 4):
print(m + 1)
1 2 3
2 3 4
0 1 2
2 3 4 5
What will be the output of the following code?
for n in range(1, 6):
print(n * 3)
3 4 5 6 7
1 2 3 4 5
0 3 6 9 12
3 6 9 12 15
What will be the output of the following code?
for x in range(4):
print(x + 2)
2 3 4 5
0 1 2 3
1 2 3 4
2 4 5 6
What will be the output of the following code?
for y in range(1, 4):
print(y ** 3)
1 4 9
1 8 27
1 2 3
1 3 5
What is the difference between = and ==
Single is like saying "make equal to" and double is comparing two values
Single does the same as double but is more efficient
There is no difference
None of the above
What would be the output from:
print("Hello"+"2"+"World")
Hello 2 World
Hello2World
Help I'm trapped
None of the above
What is the output of the following code?
a) “Can’t divide by zero”
b) “Can’t divide by zero”
“Python”
c) 1.0
d1.0
“Python”
Select one of the following options:
4
5
6
Infinite Loop
Select one of the following options:
Syntax
Infinite loop
Compilation error
None of the above
What happens if the initial condition of a while loop is false?
The loop executes once.
The loop runs indefinitely
The loop is skipped, and the code inside is not executed
The loop throws an error
In a while loop, when does the condition get evaluated?
Before each iteration
After each iteration
Only at the start of the loop
Only at the end of the loop
Select one of the following options:
0 2 4 6
0 2 4
2 4 6
0 2 4 6 8
How is the do-while loop different from the while loop?
The while loop executes the code block at least once, even if the condition is false initially
The do-while loop requires an additional condition check
The while loop requires an additional condition check
The do-while loop executes the code block at least once, even if the condition is false initially.
What does the following code snippet do?
Prints numbers 0 to 4 with spaces
Prints numbers 1 to 5 with spaces
Prints numbers 0 to 4 without spaces
Prints numbers 1 to 5 without spaces
See Answer
Hide Solution
Predict the output
2
1
3
4
