CMPUT174 Lecture 16: Poke V3 Reflection Activity Solution

89 views2 pages
ceruleanzebra152 and 30 others unlocked
CMPUT174 Full Course Notes
25
CMPUT174 Full Course Notes
Verified Note
25 documents

Document Summary

Q1 the code for the randomize method in the dot class is given. Identify the problem that may occur when we use the given code to randomize the dot. Assuming the dot class has a radius attribute, rewrite the given code to fix the problem. Given code class dot: def randomize(self): size = self. surface. get_size() for coord in range(0, 2): self. center[coord] = random. randint(0, size[coord]) Since the dot is drawn around the center, the above code could cause up to half of the dot to be outside the window surface. Fix the problem - rewrite the given code class dot: def randomize(self): size = self. surface. get_size() for coord in range(0, 2): self. center[coord] = random. randint(self. radius, size[coord] - self. radius) Q3 refer to pygame documentation and list at least four different kinds of events that are not handled in poke version 3: Q4 for each of the following python statements, write the type of object the underlined and bolded identifier is bound to:

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents