Search Header Logo
CMU CS Academy 2.21 and 2.2.2

CMU CS Academy 2.21 and 2.2.2

Assessment

Interactive Video

•

Computers

•

9th - 12th Grade

•

Practice Problem

•

Easy

Created by

Maria Cruz Farooqi

Used 2+ times

FREE Resource

37 questions

Show all answers

1.

SLIDE QUESTION

30 sec • Ungraded

2.

DRAG AND DROP QUESTION

1 min • 1 pt

Our first examples

We know how to create drawings. Now, let's make our drawings interactive, so they ​ (a)   . Exciting!

First, let's start with this example:

def ​ (b)   (x, y)​ (c)  

Circle(​ (d)   , ​ (e)   , 20)

onMousePress
:
x
y
respond to mouse presses

3.

DROPDOWN QUESTION

1 min • 1 pt

Media Image

Run the code. See how it does nothing. Well, it does ​ (a)   . It ​ (b)   the function onMousePress, and that function would ​ (c)   if it was ever called. Only, we never call the function. Odd.

Now, run that example again, only this time, ​ (d)   . You will see a new circle appear each time you click! That's what our example does!

something
defines
draw a circle
click the mouse in the canvas

4.

DRAG AND DROP QUESTION

1 min • 1 pt

The function onMousePress (x, y) is called with two ​ (a)   -- the ​ (b)   location where the mouse ​ (c)   .

parameters
x and y
was just pressed

5.

DROPDOWN QUESTION

1 min • 1 pt

Media Image

Let's change the code so the radius of the circles depend on ​ (a)   the farther to the right, the bigger:

def onMousePress(x, y):

Circle(0, 200, ​ (b)   , opacity=20)

Run the code, and click the mouse several times ​ (c)   , sometimes on the right, sometimes on the left. See that a circle is always drawn centered at the point ​ (d)   but depending where we click we draw either a big or a small circle.


where we click
x
in the canvas
(0, 200)

6.

FILL IN THE BLANK QUESTION

1 min • 1 pt

Media Image

Why does the code set the radius to x?

We want the radius to change depending on where the mouse is ______.

7.

FILL IN THE BLANK QUESTION

1 min • 1 pt

Media Image

When did we call onMousePress?

We never call onMousePress. Python calls it for us anytime we _____the mouse.

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?