Exam 13: Video Games: Multithreading, Event Handlers, Static Variables

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

Case Study 1: 1. class EventHandler: 2. def __init__(self): 3. self.__queue = [] 4. self.__eventKeeper = {} 5. 6. def addEvent(self, eventName): 7. self.__queue.append(eventName) 8. 9. def registerCallback(self, event, func): 10. self.__eventKeeper[event] = func 11. 12. def run(self): 13. while(True): 14. if len(self.__queue) > 0: 15. nextEvent = self.__queue.pop(0) 16. self.__eventKeeper[nextEvent]() 17. else: 18. print('queue is empty') -Refer to the session in the accompanying Case Study 1. What is held in self.__queue?

(Multiple Choice)
4.8/5
(40)

The turtle module's ____ method is used to register callbacks for mouse events.

(Multiple Choice)
4.7/5
(39)

A queue enforces a first-come first-served strategy for handling events.

(True/False)
4.8/5
(39)

Describe the static method in the video game presented in your text. What is special about static methods?

(Essay)
4.9/5
(34)

Which of the following parts of an event-driven program are managed by a game maker rather than by the Python event handler?

(Multiple Choice)
4.7/5
(37)

A ____ is a data structure that works like a to-do list.

(Multiple Choice)
4.8/5
(38)

The ____ function causes the thread to pause for the number of seconds passed as a parameter.

(Multiple Choice)
4.7/5
(32)

Describe the overall structure of an event-driven program.

(Essay)
4.8/5
(41)

Case Study 1: 1. class EventHandler: 2. def __init__(self): 3. self.__queue = [] 4. self.__eventKeeper = {} 5. 6. def addEvent(self, eventName): 7. self.__queue.append(eventName) 8. 9. def registerCallback(self, event, func): 10. self.__eventKeeper[event] = func 11. 12. def run(self): 13. while(True): 14. if len(self.__queue) > 0: 15. nextEvent = self.__queue.pop(0) 16. self.__eventKeeper[nextEvent]() 17. else: 18. print('queue is empty') -Refer to the session in the accompanying Case Study 1. How would you call the function associated with the key 'mouse'?

(Multiple Choice)
4.8/5
(34)

Explain the difference between a single thread of execution and multithreading.

(Essay)
4.8/5
(35)

What callback registration functions does the turtle module provide?

(Essay)
4.9/5
(34)

In a multithreaded class, the ____ method creates a new thread and calls the run method of the class inside that new thread.

(Multiple Choice)
4.8/5
(31)

A Python-mangled name that is hidden outside its class starts with a @.

(True/False)
4.8/5
(43)
Showing 21 - 33 of 33
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)