Unit 4 Review

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/23

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 3:47 AM on 4/9/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

24 Terms

1
New cards

Compound Conditionals

Conditionals that use the keywords ‘and’, ‘or’, or ‘not’ to check for multiple conditions.

2
New cards

When are ‘and’ compound conditionals true?

Only when both conditions are met.

3
New cards

When are ‘or’ compound conditionals true?

Applies when at least one conditional is met.

4
New cards

What does ‘inclusive or’ mean?

The entire ‘or’ compound conditional is true if one or both of the specified conditions are true.

5
New cards

‘not’ conditionals

Works when a condition is false.

6
New cards

Nested Conditionals

Conditions within conditions that only run when the outside condition(s) are true and the current condition is true.

7
New cards

What is ‘onStep’ used for and what does it do?

A function within CMU that allows for the app to continually change even when the user isn’t directly interacting with it (ex: mouse or keyboard press) and is primarily used to animate shapes.

8
New cards

How many times is ‘onStep’ called by default?

30 times per second.

9
New cards

What property would you use in ‘onStep’ to increase or decrease the # of times per second?

app.stepsPerSecond

  • Increasing it makes animations faster.

  • Decreasing it makes animations slower.

10
New cards

What is ‘dx’ in horizontal motion?

Its basically a value that stores how much an object’s centerX changes by for each step within onStep, and it controls the velocity of the object within the x-axis.

11
New cards

What is ‘dy’ in vertical motion?

Its basically a value that stores how much an object’s centerY changes by for each step within onStep, and it controls the velocity of the object within the y-axis.

12
New cards

How is an object’s movement affected when:

  • dx is positive.

  • dx is negative.

  • Object moves continuously towards the right.

  • Object moves continuously towards the left.

13
New cards

How can you reverse the horizontal motion of an object using dx?

Use this syntax: ‘player.dx = -player.dx’ → basically, negate the dx value to change directions.

14
New cards

How can you make an object stand still using dx?

Set dx = 0, but keep adding it to the object’s centerX.

15
New cards

How can you include ‘bounded motion’ for an object using dx?

When the object reaches the left or right edges of the canvas, set dx = 0 to make it stand still.

16
New cards

How can you include ‘wraparound motion’ for an object using dx?

When the object reaches one end of the canvas, set its centerX to appear outside of the other end to make it “reappear”.

17
New cards

How can you include ‘bouncing motion’ for an object using dx?

Negate the dx attribute (reverse direction) when the object reaches the ends of the screen.

18
New cards

How is an object’s movement affected when:

  • dy is positive.

  • dy is negative.

  • Moves down the canvas.

  • Moves up the canvas.

19
New cards

How can you reverse the vertical motion of an object using dy?

Similar to dx, negate the dy attribute using: “player.dy = -player.dy”

20
New cards

How can we manipulate dy to achieve the following:

  • Make the object stand still on the y-axis

  • Bounded Motion

  • Wraparound Motion

  • Bouncing Motion

  • Set dy = 0.

  • When the object reaches the upper/lower bound of the canvas, set dy = 0.

  • When the object passes through one end of the canvas, set its centerY outside of the other bound to make it “reappear”.

  • When the object touches an edge, negate dy (reverse its direction).

21
New cards

How can you achieve diagonal movement with dx and dy?

Manipulate both dx and dy at the same time (ie. dx and dy cannot both be 0) but they don’t have to be the same.

22
New cards

What does ‘random.randint(min, max)’ do?

Generates a random number between the min and max parameters, with the min and max also included.

23
New cards

What does ‘random.choice(listName)’ do?

Randomly selects an item from the specified list.

24
New cards

What is a way we can retrieve random items from a list without using random.choice()?

Use listName[random.randint(0, len(listName) - 1)] to randomly select a value within the list.