wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python - Coding Interpretation

Total questions: 35

Worksheet time: 24mins

Name
Class
Date
1.
What will the lines of code print?
a)
A
b)
B C
c)
A B C
d)
A C
2.
What will the following lines of code print?
a)
A
b)
B C
c)
A C
d)
Nothing, it will return an error.
3.
Which statement will check to see if a is equal to b?
a)
if a == b
b)
if a = b:
c)
if a != b:
d)
if a == b:
4.

What is the output?

a)

more than 7

b)

more than 23

c)

spam

d)

7

5.

What is syntax?

a)

a catch-all for every other situation besides true.

b)

pieces of code that direct the program to run in different ways depending on what else is happening.

c)

a set of rules for how a language is written.

d)

English, Chinese, or Spanish.

6.

Which symbol means "not equal to"?

a)

==

b)

<=

c)

>=

d)

!=

7.

Which character must be at the end of the line for if?

a)

:

b)

;

c)

.

d)

{

8.

8. If, else and elif is used for…..

a)

Selection

b)

Indentation

c)

printing

d)

iteration

9.

what is the variable name in this code?

a)

print

b)

if

c)

secret

d)

password

10.

else: is used

a)

to give an extra condition

b)

to provide an output when the other conditions are false

c)

because it is required

d)

if we do not use it, it gives error

11.

What is the output of the program

a)

4

b)

2

c)

5

d)

0

12.

Which lines are having an error in the shown code

a)

Line 1 and 2

b)

Line 2 and 3

c)

Line 3 and 4

d)

line 5 and 6

13.

what is the correct output

a)

Welcome wangchuk

b)

WelcomWangchuk

c)

Welcom Wangchuk

d)

WelcomeWangchuk

14.

write the output of the program

a)

Thinley is in class 9A

b)

Thinley is in 9A

c)

Thinleyisin9A

d)

error

15.

Data type for a whole number

a)

boolean

b)

string

c)

integer

d)

float

16.

What is the output of the following code: print 10//3

a)

3.5

b)

3

c)

1

d)

Error

17.

Which of the operator means less than equal to ?

a)

>

b)

<

c)

>=

d)

<=

18.

what is the variable name in this code?

a)

print

b)

if

c)

secret

d)

password

19.

Is this true or false?


"winter" == "Winter"

a)

False

b)

True

20.

Which of the following is an integer?

a)

8

b)

4.5

c)

print

21.

What is the result of the expression 5 * 3 - 2?

a)

13

b)

15

c)

17

d)

14

22.

Which keyword is used to define a function in Python?

a)

def

b)

function

c)

func

d)

define

23.

What will be the output of the following code: print(2 ** 3)

a)

None

b)

6

c)

8

d)

9

24.

Which of the following correctly stores 'price' as a decimal number?

a)

price = int ( input ("Price: ")

b)

price = str( input ("Price: ")

c)

price = float ( input ("Price: ")

d)

price = input ("Price: ")

25.

Put this code into the right order

a)

age = int (input ("Enter age: "))

b)

nextYear = age + 1

c)

print ("Your age next year is: " + str(nextYear))

1)
2)
3)
26.

What would the program display if you ran this code and entered 2 and then 3 when prompted?

a)

The total is 5.

b)

The total is 23.

c)

The total is 6.

d)

An error.

27.

Which lines are having an error in the shown code

a)

Line 1 and 2

b)

Line 2 and 3

c)

Line 3 and 4

d)

line 5 and 6

28.

What is the primary purpose of a for loop in Python as described in the text?

a)

To execute a block of code a limited number of times based on a condition

b)

To generate random numbers

c)

To define functions

d)

To import libraries

29.

what is the name of the variable used in the following code?

a)

counter

b)

print

c)

for

d)

#

30.

What is the output of the program above

a)

10

b)

15

c)

18

d)

17

e)

16

31.

A while loop equivalent of the for loop above is

a)
b)
c)
d)
32.

What does this program print

a)

2 + 2 = 4

4 + 4 = 8

8 + 8 = 16

16 + 16 = 32

32 + 32 = 64

b)

2 + 2 = 4

2 + 2 = 4

2 + 2 = 4

2 + 2 = 4

2 + 2 = 4

c)

2 + 2 = 4

2 + 4 = 6

2 + 6 = 8

2 + 8 = 10

2 + 10 = 12

d)

2 + 2 = 4

2 + 2 = 4

2 + 2 = 4

2 + 2 = 4

e)

2 + 2 = 4

2 + 4 = 6

2 + 6 = 8

2 + 8 = 10

33.

for i in 100 :

print ( i )

a)

Syntax error

b)

prints numbers 0 to 100

c)

prints numbers 1 to 100

d)

prints numbers 0 to 99

e)

prints numbers 1 to 99

34.

How many times will 1 be printed

a)

3

b)

4

c)

5

d)

6

35.
a)
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
(repeated continuously)
b)
Hello world!
c)
Hello world!
break              
d)
Error