wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python.Comp Quiz (Python Coding)

Total questions: 40

Worksheet time: 31mins

Name
Class
Date
1.

The rules used to write a language is called...

a)

String

b)

Syntax

c)

Sync

d)

Solution

2.

Which function is called to display a message on the screen?

a)

input

b)

int

c)

print

d)

chr

3.

What is a variable used for?

a)

To display a message.

b)

A place for hiding data.

c)

A place for storing data.

d)

To perform calculations.

4.

Which symbol needs to be at the beginning and end of a string?

a)

()

b)

'

c)

#

d)

"

5.

Which operator is used to assign a value?

a)

<=

b)

==

c)

!=

d)

=

6.

The == operator is used to ______ a value.

a)

change

b)

compare

c)

assign

d)

add

7.

Look at the code shown.

What is the output of this code?

a)

practice makes perfect

b)

line

c)

perfect makes practice

d)

print(line)

8.

How many degrees in a revolution?

a)

450o

b)

60o

c)

120o

d)

360o

9.

What is the first line of code required in an algorithm to draw with the turtle?

a)

From turtle import *

b)

From Turtle Import

c)

from turtle import *

d)

from microbit import *

10.

An algorithm is defined as...

a)

the symbols for add, subtract, multiply and divide.

b)

a requirement for something else to happen.

c)

the steps and decisions needed to perform an action or solve a problem.

d)

a program that can make decisions using if and else.

11.

What is the symbol used in Python to represent divide?

a)

\

b)

/

c)

_

d)

%

12.

What is the symbol used in Python to represent multiply?

a)

x

b)

X

c)

*

d)

#

13.

What is the output of the code shown?

a)

12

b)

11

c)

56

d)

65

14.

What is the output of the code shown?

a)

333

b)

25

c)

555

d)

15

15.

If it is raining, which colour arrow should be followed?

a)

Black

b)

Blue

c)

Green

d)

Red

16.

What would the turtle draw from the code shown?

a)
b)
c)
d)
17.

A variable can be inserted into a string using an...

a)

e-string

b)

f-string

c)

x-string

d)

i-string

18.

What term is used for a requirement for something else to happen. It can be True or False.

a)

Algorithm

b)

Condition

c)

Prompt

d)

Indentation

19.

Which function can be used to ask the user to enter a response?

a)

ord

b)

print

c)

int

d)

input

20.

Which function converts a string to a number?

a)

range

b)

int

c)

chr

d)

ord

21.

If the user typed Shazam as their response to the question in the code, what would be the output?

a)

Na na na na na na na na Batman!

b)

hero is pretty good.

c)

Batman for the win!

d)

Shazam is pretty good.

22.

The colour of the pen can be changed using...

a)

pencolor()

b)

pensize()

c)

penup()

d)

pendown()

23.

Multiple conditions can be added to an if statement using...

a)

if

b)

elif

c)

else

d)

or

24.

If the user typed Walster in response to the question in the code, what would be the output?

a)

Iguanadon

b)

Walsterdon

c)

Namedon

d)

inputdon

25.

What is the output of the code shown?

a)
b)
c)
d)
26.

A comment (or notes) in python code should begin with a...

a)

%

b)

#

c)

@

d)

!

27.

Which function controls the number of times a loop occurs?

a)

print

b)

range

c)

ord

d)

input

28.

If the user entered 6 for the above, what would be the output?

a)

x is less than three

b)

six

c)

x is equal to three

d)

x is greater than three

29.

What is the output of this code?

a)

I like pie!

b)

11

c)

!eip ekil I

d)

8

30.

Which argument will be replaced?

a)

Hello

b)

Goodbye

31.

The for command allows a set of instructions to...

a)

loop

b)

delete

c)

print

d)

run

32.

What is the output of the code shown?

a)

[space]

b)

t

c)

i

d)

e

33.

If the word digital was typed in response to the code, what would be the output?

a)

a

b)

g

c)

l

d)

t

34.

The def command is used to...

a)

define a function

b)

call a function

c)

print a function

d)

calculate a function

35.

A Function is defined as...

a)

the position of a point along the x-axis

b)

a block of reusable code that performs a specific task.

c)

a placeholder for any required arguments.

d)

information we need to give a function so it can do its job.

36.

What colour value is 'ff'?

a)

10

b)

0

c)

240

d)

255

37.

What does this line of code allow you to do?

a)

Print a function that has been defined.

b)

Test a function that has been defined.

c)

Display a function that has been defined.

d)

Calculate a function that has been defined.

38.

What is the colour model used to represent colours on the computer?

a)

Indexed Color

b)

Lab Color

c)

RGB

d)

CMYK

39.

What does execute mean in terms of computer programming?

a)

To define a function.

b)

To run or carry out an instruction or program.

c)

To give a function so it can do its job.

d)

To perform a specific task.

40.

Which command fills the background of an image?

a)

fillcolor()

b)

end_fill()

c)

bgcolor()

d)

begin_fill()