wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python

Total questions: 40

Worksheet time: 28mins

Name
Class
Date
1.
What will the output be from the following code?
print("Hello world!\nHello world!")
a)
Hello world! Hello world!
b)
Hello world!
Hello world!
c)
SyntaxError
d)
Hello world!
2.

Code executed based on a condition being true

a)

Sequence

b)

Condition

c)

Iteration

d)

Variable

3.

What does the following code do?

myAge = int (myAge)

a)

Converts the var (variable) myAge to a string

b)

Converts the var (variable) myAge to a integer

c)

Converts the var (variable) myAge from a integer to a string

d)

Converts the var (variable) myAge to if statement

4.

What is Python named after

a)

The snake

b)

Television show called Monty Python

c)

Surname of the creator

d)

Combination of names of the creators

5.
What will the output be from the following code?
print(Hello world!)
a)
Hello world!
b)
SyntaxError
c)
Hello world
d)
print(Hello world!)
6.

Used to create a function

a)

const

b)

int

c)

def

d)

while

7.
Python identifies blocks of code by
a)
BEGIN and END keywords
b)
{ and }
c)
aligning up the starts of lines (indentation)
d)
guessing
8.

What does the term 'debug' mean?

a)

Identify errors and fix them

b)

Making a calculation

c)

A set of instructions

d)

Looking at code

9.
Joining elements together to make a string is called what?
a)
Combining
b)
Connecting
c)
Concatenation
d)
Stringing
10.

If you want more than one option for your code, what do you use (after if)?

a)

elif

b)

else

c)

ifif

d)

else if

11.

What would this result be?

people = ["John", "Rob", "Bob"]

print (people[1])

a)

John

b)

Rob

c)

Bob

12.
What is the name of the environment in Python that write your programs and then test them out?
a)
Shell
b)
Window
c)
IDLE
d)
CLI
13.
What extension must you add to the end of a file when saving?
a)
.xlsx
b)
.pptx
c)
.docx
d)
.py
14.

What does the print function do in python?

a)

It's a variable

b)

It can input data

c)

It displays something like a string or integer

d)

It loops the code

15.
What symbol do you use to make a comment in Python?
a)
@
b)
¬
c)
;
d)
#
16.
In python the ' STRING data type' can be defined as...?
a)
holds alphanumeric text
b)
hold whole numbers
c)
holds numbers with a decimal point
d)
holds either a true or false value
17.
In python the ' INTEGER data type' can be defined as...?
a)
holds alphanumeric data as text
b)
holds whole numbers
c)
holds numbers with a decimal point
d)
holds either ‘true’ or ‘false’
18.
In python the ' BOOLEAN data type' can be defined as...?
a)
holds alphanumerical data
b)
holds whole numbers
c)
holds a number with a decimal point
d)
holds either true or false
19.
What is the correct definition for 'pseudo code?'
a)
a notation resembling a complex programming language, used in program design.
b)
a notation resembling a simplified programming language, used in program design.
20.

What is the code for a STRING in python?

a)

str

b)

stri

c)

stg

21.

What is correct code for INTEGER in python?

a)

in

b)

ing

c)

int

22.

I am 71 years old! What will the output be?:

IF you are 70 or older, say “You are aged to perfection!”

ELIF you are exactly 50, say “Wow, you are half a century old!”

ELSE say “You are a spring chicken!”

a)

“You are aged to perfection!”

b)

"Wow, you are half a century old!"

c)

"You are a spring chicken!"

23.

I am 18 years old! What will the output be?:

IF you are 70 or older, say “You are aged to perfection!”

ELIF you are exactly 50, say “Wow, you are half a century old!”

ELSE say “You are a spring chicken!”

a)

"You are aged to perfection"

b)

"Wow, you are half a century old!"

c)

"You are spring chicken!"

24.

Look at this code, how many times will it loop?

a)

3

b)

1

c)

0

d)

4

25.
Look at this code, what shape will it make?
a)
Square
b)
Triangle
c)
Rectangle
d)
Hexagon 
26.
What is wrong with this code?
a)
Missing Brackets
b)
Missing Comma
c)
Missing Colon
d)
Incorrect spelling 
27.
What is wrong with this code?
a)
Missing Brackets
b)
Missing Comma
c)
Missing Colon
d)
Incorrect spelling 
28.
What will be the output from this code?
a)
A star with an orange outline
b)
A solid orange star
c)
A pentagon with an orange outline
d)
A solid orange pentagon
29.
What will be the output from this code?
a)
A pentagon with an orange outline
b)
A solid orange star
c)
A star with an orange outline
d)
A solid orange pentagon
30.
To stop the turtle drawing you need to use which of the following commands?
a)
penup:
b)
pen_up( )
c)
penup( )
d)
penup( ):
31.
To move the turtle to  a specific position on the drawing canvas you need to use which of the following commands?
a)
set_pos( )
b)
setpos( ):
c)
setpos
d)
setpos( )
32.
When using a command to move the turtle to a specific position on the drawing canvas, the middle of the canvas is represented by which coordinates?
a)
1, 1
b)
100, 100
c)
0, 0
d)
500, 500
33.

Used to structure code in Python

a)

Whitespace

b)

Comments

c)

Booleans

d)

Variables

34.

a data type than can have one of two values: True or False

a)

Boolean

b)

Variable

c)

Modulo

d)

Interpreter

35.
The correct way to write a variable in Python?
a)
my_variable = 10
b)
my variable = 10
c)
my_variable is 10
d)
my_variable: 10
36.

What will the output be from the following code?

print( 3 + 4 )

a)

3 + 4

b)

7

c)

SyntaxError

d)

print( 3 + 4 )

37.
To repeat a fixed number of times use a
a)
while loop
b)
for loop
c)
if loop
d)
indentation
38.
The character that must be at the end of the line for if, while, for etc.
a)
:
b)
;
c)
.
d)
,
39.
To repeat until a particular condition is true use
a)
while loop
b)
for loop
c)
if loop
d)
indentation
40.
Which of these would work as a piece of code?
a)
IF answer == "Yes":
b)
if answer == "Yes"
c)
if answer == "Yes":
d)
if answer = "yes":