
CMU CS Academy 2.21 and 2.2.2
Interactive Video
•
Computers
•
9th - 12th Grade
•
Practice Problem
•
Easy
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)
3.
DROPDOWN QUESTION
1 min • 1 pt
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!
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) .
5.
DROPDOWN QUESTION
1 min • 1 pt
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.
6.
FILL IN THE BLANKS QUESTION
1 min • 1 pt
Why does the code set the radius to x?
We want the radius to change depending on where the mouse is (a) .
7.
FILL IN THE BLANKS QUESTION
1 min • 1 pt
When did we call onMousePress?
We never call onMousePress. Python calls it for us anytime we (a) the mouse.
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?