Exam 13: Video Games: Multithreading, Event Handlers, Static Variables
Exam 1: Introduction to Python: Introduction to Numeric Types, Turtle Graphics, Simple for Loops and Functions34 Questions
Exam 2: Pthon: Estimating PI: Math and Random Methods, Selection and Boolean Expressions, the Print Function33 Questions
Exam 3: Codes and Other Secrets: String Operators and Methods, the Len Built-In Function, Keyword Parameters, User Input33 Questions
Exam 4: Introducing the Python Collections: Lists, Dictionaries, Tuples, and Statistics33 Questions
Exam 5: Bigger Data: File Io: the While Loop, String Formatting, Reading Online Data in CSV and Json Formats33 Questions
Exam 6: Image Processing: Nested for Loops, Functions As Parameters, Namespaces, Lists of Lists33 Questions
Exam 7: Data Mining: Cluster Analysis: More on the While Loop; Parrallel Lists31 Questions
Exam 8: Cryptanalysis: Advanced Dictionaries and Lists, Regular Expressions32 Questions
Exam 9: Fractals: the Geometry of Nature: Recursion, Grammars and Production Rules33 Questions
Exam 10: Astronomy: Creating Classes, Writing Constructors, Accessors, Mutators and Special Methods33 Questions
Exam 11: Simulation:computer Simulation Using Objects34 Questions
Exam 12: Father Was a Rectangle: Inheritance and Object-Oriented Design32 Questions
Exam 13: Video Games: Multithreading, Event Handlers, Static Variables33 Questions
Select questions type
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)
The ____ function causes the thread to pause for the number of seconds passed as a parameter.
(Multiple Choice)
4.7/5
(32)
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)
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
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)