WorksheetsPython Intermediate Quiz (Including pygame)
Total questions: 20
Worksheet time: 14mins
Which function of pygame is used to set the title ?
pygame.display.set_title()
pygame.display.set_caption()
pygame.display.title()
none
Which pygame function is used to set the size of the window?
pygame.display.set_mode()
pygame.display.set_size()
pygame.display.set_screen()
none
Which function in pygame is used to make changes to the window ?
pygame.display.change()
pygame.display.change()
pygame.window.update()
pygame.display.update()
What does the following command do?
pygame.image.load()
Displays an image on the window
Loads an image from a file
Updates the window
How can we load a sound file in pygame?
pygame.add.Sound()
pygame.sound.load()
pygame.mixer.sound()
pygame.mixer.Sound()
Which operator returns the remainder from division
division
exponents
boolean
modulus
people = ["John", "Rob", "Bob"]
print (people[1])
what would this result be?
people = ["John", "Rob", "Bob"]
print (people[-1])
what would this result be?
Which of the following are true of Python lists? Select all the correct statements.
These represent the same list:['a', 'b', 'c'] ['c', 'a', 'b']
A given object may appear in a list more than once
All elements in a list must be of the same type
A list may contain any type of object except another list
There is no conceptual limit to the size of a list
Which of the following are true of Python dictionaries? Select all the correct statements.
Dictionaries can be nested to any depth.
Dictionaries are accessed by key.
All the keys in a dictionary must be of the same type.
Dictionaries are mutable.
A dictionary can contain any object type except another dictionary.
Which one will display when this code is run?
Which tuple of RGB code is representing the color black ?
(255,255,255)
(0,0,0)
(0,255,0)
(0,0,255)
The keyword used to make the anonymous function is -
def
anonymous
lambda
import
Which of the following is not a valid way to define this dictionary in Python:
d = dict([
('foo', 100),
('bar', 200),
('baz', 300)
])
d = {}
d['foo'] = 100
d['bar'] = 200
d['baz'] = 300
d = {'foo': 100, 'bar': 200, 'baz': 300}
d = { ('foo', 100), ('bar', 200), ('baz', 300) }
You have the following dictionary definition:
d = {'foo': 100, 'bar': 200, 'baz': 300}
What method call will delete the entry whose value is 200?
d.pop(200)
d.pop("bar")
d.remove("bar")
d.delete("bar")
What would be the output of this code:
hello! hello! hello! hello!
2 4 6 8
hello!
2 hello! 4 hello! 6 hello! 8 hello!
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?
x[2]["bar"][2]
x[2]["bar"]
x["bar"][2]
x[2][2]
What will be the output of code shown in the image?
Original Tuple: (1, 2, 3)
New tuple: (1, 2, 3, 5)
Original Tuple: (1, 2, 3)
New tuple: (1, 5, 3)
Error
Original Tuple: (1, 2, 3)
New tuple: (1, 2, 3)
Which of the following data types are immutable?
String
List
Tuple
Dictionary
Integer
What will be the output of the code in the image?
Error
