wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Intermediate Quiz (Including pygame)

Total questions: 20

Worksheet time: 14mins

Name
Class
Date
1.

Which function of pygame is used to set the title ?

a)

pygame.display.set_title()

b)

pygame.display.set_caption()

c)

pygame.display.title()

d)

none

2.

Which pygame function is used to set the size of the window?

a)

pygame.display.set_mode()

b)

pygame.display.set_size()

c)

pygame.display.set_screen()

d)

none

3.

Which function in pygame is used to make changes to the window ?

a)

pygame.display.change()

b)

pygame.display.change()

c)

pygame.window.update()

d)

pygame.display.update()

4.

What does the following command do?

pygame.image.load()

a)

Displays an image on the window

b)

Loads an image from a file

c)

Updates the window

5.

How can we load a sound file in pygame?

a)

pygame.add.Sound()

b)

pygame.sound.load()

c)

pygame.mixer.sound()

d)

pygame.mixer.Sound()

6.

Which operator returns the remainder from division

a)

division

b)

exponents

c)

boolean

d)

modulus

7.

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

print (people[1])

what would this result be?

a)
John
b)
Rob
c)
Bob
8.

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

print (people[-1])

what would this result be?

a)
John
b)
Rob
c)
Bob
9.

Which of the following are true of Python lists? Select all the correct statements.

a)

These represent the same list:['a', 'b', 'c'] ['c', 'a', 'b']

b)

A given object may appear in a list more than once

c)

All elements in a list must be of the same type

d)

A list may contain any type of object except another list

e)

There is no conceptual limit to the size of a list

10.

Which of the following are true of Python dictionaries? Select all the correct statements.

a)

Dictionaries can be nested to any depth.

b)

Dictionaries are accessed by key.

c)

All the keys in a dictionary must be of the same type.

d)

Dictionaries are mutable.

e)

A dictionary can contain any object type except another dictionary.

11.

Which one will display when this code is run?

a)
b)
c)
d)
12.

Which tuple of RGB code is representing the color black ?

a)

(255,255,255)

b)

(0,0,0)

c)

(0,255,0)

d)

(0,0,255)

13.

The keyword used to make the anonymous function is -

a)

def

b)

anonymous

c)

lambda

d)

import

14.

Which of the following is not a valid way to define this dictionary in Python:

a)

d = dict([

('foo', 100),

('bar', 200),

('baz', 300)

])

b)

d = {}

d['foo'] = 100

d['bar'] = 200

d['baz'] = 300

c)

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

d)

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

15.

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)

d.pop(200)

b)

d.pop("bar")

c)

d.remove("bar")

d)

d.delete("bar")

16.

What would be the output of this code:

a)

hello! hello! hello! hello!

b)

2 4 6 8

c)

hello!

d)

2 hello! 4 hello! 6 hello! 8 hello!

17.

Suppose x is defined as follows:

x = ['a', 'b', {'foo': 1, 'bar': 2, 'baz': 3}, 'c', 'd']

What is the expression involving x that accesses the value 2?

a)

x[2]["bar"][2]

b)

x[2]["bar"]

c)

x["bar"][2]

d)

x[2][2]

18.

What will be the output of code shown in the image?

a)

Original Tuple: (1, 2, 3)

New tuple: (1, 2, 3, 5)

b)

Original Tuple: (1, 2, 3)

New tuple: (1, 5, 3)

c)

Error

d)

Original Tuple: (1, 2, 3)

New tuple: (1, 2, 3)

19.

Which of the following data types are immutable?

a)

String

b)

List

c)

Tuple

d)

Dictionary

e)

Integer

20.

What will be the output of the code in the image?

a)

Error

b)
c)
d)