wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Code Sprint '25

Total questions: 20

Worksheet time: 15mins

Name
Class
Date
1.

What will be the output of the following code?

for i in range (3):

print(i)

a)
3
b)
-1
c)
1.5
d)

0 1 2

2.

What will be the output of the following code?

for j in range(5):

print(j * 2)

a)

0 2 4 6 8

b)

0 1 2 3 4

c)

1 3 5 7 9

d)

2 4 6 8 10

3.

What will be the output of the following code?

for k in range(2, 5):

print(k ** 2)

a)

2 3 4

b)

2 3 4

c)

4 9 16

d)

1 4 9

4.

What will be the output of the following code?

for m in range(1, 4):

print(m + 1)

a)

1 2 3

b)

2 3 4

c)

0 1 2

d)

2 3 4 5

5.

What will be the output of the following code?

for n in range(1, 6):

print(n * 3)

a)

3 4 5 6 7

b)

1 2 3 4 5

c)

0 3 6 9 12

d)

3 6 9 12 15

6.

What will be the output of the following code?

for x in range(4):

print(x + 2)

a)

2 3 4 5

b)

0 1 2 3

c)

1 2 3 4

d)

2 4 5 6

7.

What will be the output of the following code?

for y in range(1, 4):

print(y ** 3)

a)

1 4 9

b)

1 8 27

c)

1 2 3

d)

1 3 5

8.

What is the difference between = and ==

a)

Single is like saying "make equal to" and double is comparing two values

b)

Single does the same as double but is more efficient

c)

There is no difference

d)

None of the above

9.

What would be the output from:

print("Hello"+"2"+"World")

a)

Hello 2 World

b)

Hello2World

c)

Help I'm trapped

d)

None of the above

10.
What's the mistake in this code?
a)
The variable "surname" needs a capital letter (first line of code)
b)
"print" needs a capital letter
c)
"input" needs a capital letter
d)
There are plus signs in the final line of code
11.
What's the mistake in this code?
a)
Capital H in "What"
b)
Misspelling of the word "input"
c)
Capital letter missing from "print"
d)
Capital letter missing from "input"
12.

What is the output of the following code?

a)

a) “Can’t divide by zero”

b)

b) “Can’t divide by zero”

  “Python”

c)

c) 1.0

d)

d1.0

     “Python”

13.

Select one of the following options:

a)

4

b)

5

c)

6

d)

Infinite Loop

14.

Select one of the following options:

a)

Syntax

b)

Infinite loop

c)

Compilation error

d)

None of the above

15.

What happens if the initial condition of a while loop is false?

a)

The loop executes once.

b)

The loop runs indefinitely

c)

The loop is skipped, and the code inside is not executed

d)

The loop throws an error

16.

In a while loop, when does the condition get evaluated?

a)

Before each iteration

b)

After each iteration

c)

Only at the start of the loop

d)

Only at the end of the loop

17.

Select one of the following options:

a)

0 2 4 6

b)

0 2 4

c)

2 4 6

d)

0 2 4 6 8

18.

How is the do-while loop different from the while loop?

a)

The while loop executes the code block at least once, even if the condition is false initially

b)

The do-while loop requires an additional condition check

c)

The while loop requires an additional condition check

d)

The do-while loop executes the code block at least once, even if the condition is false initially.

19.

What does the following code snippet do?

a)

Prints numbers 0 to 4 with spaces

b)

Prints numbers 1 to 5 with spaces

c)

Prints numbers 0 to 4 without spaces

d)

Prints numbers 1 to 5 without spaces

See Answer

Hide Solution


20.


Predict the output

a)

2

b)

1

c)

3

d)

4