6.3.5 Cmu Cs Academy May 2026
Unlike text-based problems on LeetCode or Codecademy, CMU CS Academy asks you to build shapes, animate objects, and respond to user input (mouse clicks and keyboard presses) within a 400x400 canvas. Unit 6 changes everything. In earlier units, code runs top-to-bottom and stops. In Unit 6, you write event handlers —functions that sit dormant until a specific action occurs.
In the CMU CS Academy curriculum—specifically within the (Introduction to Programming) or CS1 courses—Unit 6 is dedicated to "Events and Interactions." Section 3 focuses on keyboard input, and exercise 6.3.5 is where the rubber meets the road.
def onStep(): if moveLeft: circle.centerX -= 5 6.3.5 Cmu Cs Academy
def onAppStart(app): global circle # Create blue circle at center of 400x400 canvas circle = Circle(200, 200, 20, fill='blue') # Add it to the canvas add(circle)
def onKeyRelease(key): global moveLeft if key == 'left': moveLeft = False Unlike text-based problems on LeetCode or Codecademy, CMU
# 6.3.5 - Moving Circle with Arrow Keys # CMU CS Academy Solution circle = None
def onKeyPress(key): global circle # Movement speed speed = 15 In Unit 6, you write event handlers —functions
The boundary check uses 20 and 380 because the radius is 20. The center of a 20px radius circle at x=20 touches the edge at x=0. Common Mistakes on 6.3.5 Even smart students fail 6.3.5 on the first try. Here is why: Mistake #1: Forgetting global Every time you modify circle inside onKeyPress , you must write global circle . If you forget, Python creates a local variable named circle , and the actual circle on screen never moves. Mistake #2: Using the Wrong Key Strings Many students try: