CS 1400 EXAM 2 QUESTIONS WITH VERIFIED
ANSWERS
What are the three main parts of creating an animation in drawly? - Answers - Update,
display, setup
The animation loop contains only the update phase of the animation process. - Answers
- FALSE
What is the main difference between an animation and a game? - Answers - Games
have user input.
What is the purpose of the flip() function - Answers - It draws the pygame window
what module in pygame should one use to draw a circle - Answers - draw
what does pygame.key.get_pressed() return - Answers - A list of booleans
What is the name of the function that allows you to add an image to the screen? -
Answers - blit()
For a screen size of 1280x720, if I add an image at location 640x360 the image will be
centered on the screen. - Answers - FALSE
What module contains the function necessary to add an image to a program? - Answers
- image
Which of the following lines of code are associated with playing background music for a
game? - Answers - pygame.mixer.music.load("music.mp3") AND
pygame.mixer.music.play(-1)
Code to play sound effects must appear in the same area where the screen is updated.
- Answers - FALSE
Which of the following is a proper function header (the text between 'def' and ':' when
defining a function) for the object initializer? - Answers - __init__(self)
the first parameter of the initializer should always be self - Answers - TRUE
What is a more specific name for a variable that is defined to be part of an object? -
Answers - instance variable
What is the parameter self? - Answers - it is how an object refers to itself
, Objects can store data and also have _________________. - Answers - capabilities
What is the symbol of the operator that used in order to access a capability of a list? -
Answers - .
For a string name my_string how would I access a capability that returns the stored
string in all lowercase letters? - Answers - my_string.lower()
Mark all of the following that are true about classes and objects. - Answers - classes
should be defined in its own module (file), the first parameter of methods should always
be self, objects store data and have capabilities. These are all defined in the class.
Why can two different objects call the same method and have different results? -
Answers - Methods can use instance variables stored in the specific object
With a method call, every time I give the same input as parameters the output will
always be the same. - Answers - false
What must be true about the following code? You may assume the following code does
not produce errors.
my_widget = Widget("blue", 10) # This is creating an object my_widget.grow()
my_widget.print() - Answers - grow() is a method, grow() and print() are both defined in
the Widget class
The first parameter in a method definition will always be self. - Answers - TRUE
What is the event type when a mouse button is pressed? - Answers -
MOUSEBUTTONDOWN
The get_pressed() function returns the location of the mouse when the mouse button is
being held down. - Answers - FALSE
What is the name of the method that returns the x, y coordinate of the mouse? -
Answers - pygame.mouse.get_pos()
The distance formula can be used to determine if a mouse click happens in a circle, but
isn't accurate for other shapes. - Answers - TRUE
What is the output of the following code?
result = "I am Groot!".split()
print(result) - Answers - ['I', 'am', 'Groot!']
What is the output of the following program?
result = input("Enter two numbers: ").split()
print(result[0] + result[1]) - Answers - 52
ANSWERS
What are the three main parts of creating an animation in drawly? - Answers - Update,
display, setup
The animation loop contains only the update phase of the animation process. - Answers
- FALSE
What is the main difference between an animation and a game? - Answers - Games
have user input.
What is the purpose of the flip() function - Answers - It draws the pygame window
what module in pygame should one use to draw a circle - Answers - draw
what does pygame.key.get_pressed() return - Answers - A list of booleans
What is the name of the function that allows you to add an image to the screen? -
Answers - blit()
For a screen size of 1280x720, if I add an image at location 640x360 the image will be
centered on the screen. - Answers - FALSE
What module contains the function necessary to add an image to a program? - Answers
- image
Which of the following lines of code are associated with playing background music for a
game? - Answers - pygame.mixer.music.load("music.mp3") AND
pygame.mixer.music.play(-1)
Code to play sound effects must appear in the same area where the screen is updated.
- Answers - FALSE
Which of the following is a proper function header (the text between 'def' and ':' when
defining a function) for the object initializer? - Answers - __init__(self)
the first parameter of the initializer should always be self - Answers - TRUE
What is a more specific name for a variable that is defined to be part of an object? -
Answers - instance variable
What is the parameter self? - Answers - it is how an object refers to itself
, Objects can store data and also have _________________. - Answers - capabilities
What is the symbol of the operator that used in order to access a capability of a list? -
Answers - .
For a string name my_string how would I access a capability that returns the stored
string in all lowercase letters? - Answers - my_string.lower()
Mark all of the following that are true about classes and objects. - Answers - classes
should be defined in its own module (file), the first parameter of methods should always
be self, objects store data and have capabilities. These are all defined in the class.
Why can two different objects call the same method and have different results? -
Answers - Methods can use instance variables stored in the specific object
With a method call, every time I give the same input as parameters the output will
always be the same. - Answers - false
What must be true about the following code? You may assume the following code does
not produce errors.
my_widget = Widget("blue", 10) # This is creating an object my_widget.grow()
my_widget.print() - Answers - grow() is a method, grow() and print() are both defined in
the Widget class
The first parameter in a method definition will always be self. - Answers - TRUE
What is the event type when a mouse button is pressed? - Answers -
MOUSEBUTTONDOWN
The get_pressed() function returns the location of the mouse when the mouse button is
being held down. - Answers - FALSE
What is the name of the method that returns the x, y coordinate of the mouse? -
Answers - pygame.mouse.get_pos()
The distance formula can be used to determine if a mouse click happens in a circle, but
isn't accurate for other shapes. - Answers - TRUE
What is the output of the following code?
result = "I am Groot!".split()
print(result) - Answers - ['I', 'am', 'Groot!']
What is the output of the following program?
result = input("Enter two numbers: ").split()
print(result[0] + result[1]) - Answers - 52