Search Header Logo

Understanding Event Functions and onStep in Python

Authored by Keith Lavigne

Computers

9th Grade

Used 1+ times

Understanding Event Functions and onStep in Python
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

9 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of the onStep function?

To handle mouse click events.

To execute code once per second as defined by app.stepsPerSecond.

To define the color of shapes.

To initialize the application.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How many times does onStep run if app.stepsPerSecond is set to 1?

Once per minute

Once per second

Twice per second

Ten times per second

3.

OPEN ENDED QUESTION

3 mins • 1 pt

Your CMU CS Academy app has defined app.shapes as a python list.

Assume that the following local variables have appropriate values stored in them:

leftX, topY, wth, hgt

define an appropriate function that adds a new rectangle object to the list when the mouse is released.

Evaluate responses using AI:

OFF

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

The function definition for onMouseRelease is:

def onMouseRelease(mouseX, mouseY):

What data is accessible locally inside the function's implementation?

mouseX, mouseY, mouseZ
mouseX, mouseY
mouseX, screenY
mouseX, mouseY, buttonPressed

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

In python, which method is calledto add data to the end of a list?

add
insert
extend
append

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

In computer programming, what is the meaning of the term mutability?

Mutability refers to the speed of a program's execution.
Mutability is the process of creating new objects without modifying existing ones.
Mutability is the ability of an object to be changed after its creation.
Mutability means an object cannot be altered once created.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

In your CMU CS Academy App, you have declared a python list named app.shapes.

Each time the onStep function triggers, you want to traverse the entire list of shapes. What code would your write to make this happen?

while shape in app.shapes:
for shape in app.shapes: # perform actions with shape
foreach shape in app.shapes:
for shape in app.shapes():

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?