def onKeyPress(key): global circle # Movement speed speed = 15
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 onKeyPress(key): circle.centerX += 15 # Error: circle is not defined
This article will break down exactly what 6.3.5 requires, the core concepts you need to master, common pitfalls, and a step-by-step strategy to solve it efficiently. Before we dissect the specific exercise, let's establish the platform. CMU CS Academy is a free, online, project-based curriculum developed by Carnegie Mellon University. It uses a custom, simplified version of Python (built around the cmu_graphics library) to teach computer science fundamentals through visual, interactive graphics.
# Hold-to-move (smooth) moveLeft = False def onKeyPress(key): global moveLeft if key == 'left': moveLeft = True
def onStep(): if moveLeft: circle.centerX -= 5

