wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Assessment

Total questions: 31

Worksheet time: 22mins

Name
Class
Date
1.

Code for Hello, World!

a)

print Hello, World!

b)

print("Hello, World!)

c)

print("Hello, World!")

2.

Code for

Five is greater than two!

a)

if 5 > 2:

print("Five is greater than two!")

b)

if 5 = 2:

print("Five is greater than two!")

c)

if 5 > 2: Print("Five is greater than two!")

3.

The output of the program

x = 4

x = "Sally"

print(x)

a)

four

b)

Saly

c)

Sally

4.

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

print (people[1])

what would this result be?

a)
John
b)
Rob
c)
Bob
5.
What syntax can you use to insert a line break between strings so that they appear over multiple lines?
a)
/
b)
\n
c)
\l
d)
n
6.
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
7.
What is syntax?
a)
Syntax is the word used to describe an error
b)
Syntax is the rules of the programming language
c)
It is used to read information
d)
It is used to output information 
8.
What will the output be from the following code?
print("Hello" + str(2) + "world!")
a)
Hello world! Hello world!
b)
Hello2world!
c)
Hello Hello world! world!
d)
SyntaxError
9.
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!
10.

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

print (people[-1])

what would this result be?

a)
John
b)
Rob
c)
Bob
11.

What would be the output of this program if the user entered "yes" then "what"?

a)

Enjoy your day

b)

it is too windy for an umbrella

c)

Take an umbrella

d)

Error

12.

What type of list is being used in this example?

a)

Dictionary

b)

List

c)

Tuple

d)

2d Array

13.

What would be the output of this program if the user input was 10?

a)

22.04

b)

220.4

c)

2204

d)

Error wrong data type

14.

How many variables are there in this program?

a)

2

b)

3

c)

4

d)

5

15.

Which of the following statements is true?

a)

Python is a high level programming language.

b)

Python is an interpreted language.

c)

Python is an object-oriented language.

d)

Python is found in Amazon forest.

16.

What will be the output of the following Python code?

def cube(x):

return x * x * x


x = cube(3)

print (x)

a)

9

b)

3

c)

27

d)

30

17.

What is the correct order of the following?

a)

if

elif

else

b)

if

elif

else

elif

c)

if

else

elif

d)

else

if

18.

Which keyword is used for an infinite loop or ITERATION?

a)

else

b)

if answer == "right":

c)

while True:

d)

elif

19.

There is a mistake on line 1 of this program. Write the instructions with the corrections.

Be careful with spaces when writing your answer or the quiz will not recognise your answer!

(a)  

20.

A Python dictionary stores ...

a)

value - key pairs

b)

key - value pairs

21.

You have the following dictionary definition:


d = {'foo': 100, 'bar': 200, 'baz': 300}


What method call will delete the entry whose value is 200?

a)

delete d('bar')

b)

d.pop("bar")

c)

d.remove("bar")

d)

None of the above

22.

What would be the output of the following code snippet?


a_dict = {'color': 'blue', 'fruit': 'apple', 'pet': 'dog'}

d_items = a_dict.items()

print(d_items)

a)

('color', 'blue'), ('fruit', 'apple'), ('pet', 'dog')

b)

dict_items([('color'), ('fruit'), ('pet')])

c)

[('color', 'blue'), ('fruit', 'apple'), ('pet', 'dog')]

d)

dict_items([('color', 'blue'), ('fruit', 'apple'), ('pet', 'dog')])

23.

Select the correct answer:


x = 15

y = 4


print(x // y)

a)

3

b)

3.75

c)

4

d)

5

24.

variable.sort() will do what?

a)

Sort the list into alphabetical order

b)

Sort the list into reverse order

c)

Create a new list

d)

Error

25.

What is the output of program below?


mariana_islands = ['Saipan', 'Tinian', 'Rota']

mariana_islands.remove('Tinian')

print(mariana_islands)

a)

['Saipan', 'Tinian', 'Rota']

b)

['Tinian', 'Rota']

c)

['Saipan', 'Tinian']

d)

['Saipan', 'Rota']

26.

What is the output of program below?


mariana_islands = ['Saipan', 'Tinian', 'Rota', 'Guam']

mariana_islands.sort()

print(mariana_islands)

a)

['Tinian', 'Saipan', 'Rota', 'Guam']

b)

['Guam', 'Tinian', 'Rota', 'Saipan']

c)

['Saipan', 'Rota', 'Guam', 'Tinian']

d)

['Guam', 'Rota', 'Saipan', 'Tinian']

27.

What is the default return value for a function that does not return a value explicitly?

a)

None

b)

int

c)

double

d)

null

28.

Pick one from the following statements to correctly complete the function body to get the output 5 in the given code snippet:


def f(number):

#missing function body


print(f(5))

a)

return "number"

b)

print(number)

c)

print("number")

d)

return number

29.

What will this code do?

a)

Print Numbers 1-11

b)

Print Numbers 1-10

c)

Print Numbers 2-10

d)

Print Error

30.
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!"
31.

It has been an honour taking you through the Python programming Journey.

All the best in your path. Continue practicing to even get better.

Have a good one 💫

By Ms Edith.

This is a section for you to write feedback.

4 lines