Search Header Logo
U2L1-2 Review ^^

U2L1-2 Review ^^

Assessment

Presentation

Computers

9th - 10th Grade

Medium

Created by

TIFFANY WONG

Used 10+ times

FREE Resource

7 Slides • 9 Questions

1

media

U2L1-2 Review ^^

Presented by kaufwong©

media

2

Multiple Select

Which of the following are GLOBAL variables? Choose one or more.

1
2
3
4

3

​Global vs. Local Variables

​A global variable is one that ALL sprites and scripts can access.

shopping list is a global variable. The sprites "add," "clear," and "delete" all access shopping list and make changes to it.

media
media
media

4

​​Global vs. Local Variables

A local variable is limited to the scope in which its defined.

​In other words, secret number can ONLY be used in the definition of number guessing game.

media

​​If you try to use secret number outside of number guessing game, you'll get an error.

5

​More on local variables

We use local variables because using global variables sometimes makes it difficult to debug.

​Having too many global variables also clutters our variable palette...

So when you're wondering if it should use a global or local variable, ask: do multiple scripts/sprites need to use it??

media
media
media

​vs

6

Multiple Select

Which of the following are LOCAL variables? Choose one or more.

1
2
3
4

7

More on local variables

​Yes, input variables are also local!

​They cannot be used outside of the procedure in which they are defined.

media

8

Fill in the Blanks

Type answer...

9

Fill in the Blanks

Type answer...

10

Multiple Select

In which of the following instances should you use global variables instead of local variables? Choose one or more.

1

Keeping track of a player's score throughout an event-based game with many different triggers

2

Making an abstraction called "pythagorean thm" that takes in two numbers and calculates the third side

3

Making an app that manages a to-do list with various sprites as buttons that each have a different feature

4

Counting the number of times the user makes a guess, but the variable is used only in this script

11

Variables vs Lists

A list can hold more than one value at a time, and the values are ordered. A variable can only hold one value at a time.

​Shopping list app is very hard to do with just variables :(

​​You don't know how many variables you need to create because you need one for every item the user will add (and who knows how many they'll add!). A list is better because it can hold as many values as the user wants to add.

media

12

Multiple Choice

Running which of the following scripts will result in shopping list being an empty list?

1
2
3
4

13

Multiple Select

Running which of the following scripts will make the sprite say "0" ? Choose one or more.

1
2
3
4

14

Multiple Choice

shopping list = [eggs, milk, bread]. Which of the following will make shopping list [eggs, milk, cheese, bread] ?

1
2
3
4

15

​The index of an item in the list refers to its order in the list.

​​shopping list = [eggs, milk, bread]

​The first item, eggs, is at index 1

​The length of the list refers to the number of items inside.

​We want [eggs, milk, cheese, bread]

media
media
media
media
media
media
media
media
media
media
media
media
media
media

add adds items to the end, i.e. append in pseudocode

16

Multiple Choice

The delete blocks takes in a number and a list as inputs. Which of the following scripts will delete bread from the shopping list?

1
2
3
4
media

U2L1-2 Review ^^

Presented by kaufwong©

media

Show answer

Auto Play

Slide 1 / 16

SLIDE