What’s wrong?
x and y are local variables — they disappear when the method ends. The method never updates self.x or self.y, so the particle stays put.
Fix: Add an else branch: self.x = x and self.y = y
(POGIL Q15: attributes live on self, local variables don’t.)
Which line goes inside this loop to move each particle?
self.move(HALF_SIZE)Particle.move(HALF_SIZE)p.move(HALF_SIZE)move(p, HALF_SIZE)Answer: C. p is the object; call the method on it with dot notation.
self only exists inside a method definition (POGIL Q13).Particle is the class, not an instance — and self wouldn’t get filled in.move is a method, not a global function.def add_particle():
radius = randint(5, 25)
x = randint(-(HALF_SIZE - 25), HALF_SIZE - 25)
y = randint(-(HALF_SIZE - 25), HALF_SIZE - 25)
vel_x = randint(-(radius // 10), radius // 10)
vel_y = randint(-(radius // 10), radius // 10)
color = get_random_color()
Particle(x, y, vel_x, vel_y, radius, color)This runs without errors. Why doesn’t a particle appear?
The Particle is created but never added to the list.
Fix: particles.append(Particle(x, y, vel_x, vel_y, radius, color))
The main loop draws everything in particles — if it’s not in the list, it won’t show up.
The method runs without error. Why doesn’t it work?
The boolean expression is evaluated but not returned. Python methods return None by default, and None is falsy.
Fix: return distance(click_x, click_y, self.x, self.y) < self.radius