Search Header Logo

BJC U2L1 Global vs. Local Variables

Authored by TSEE LEE

Computers

10th Grade - University

Used 32+ times

BJC U2L1 Global vs. Local Variables
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

11 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

45 sec • 10 pts

Media Image

What will the script say?

50, 50, 50

50, 60, 60

50, 60, 50

60, 60, 50

Answer explanation

The custom block (procedure) creates a script variable, which is temporary & exists only for the duration of that block. The script variable is erased from existence when the block finishes.

2.

MULTIPLE CHOICE QUESTION

30 sec • 10 pts

A local variable is

a variable that is limited in scope

is the same as a constant

can be accessed anywhere in the program

is the same as a block

Answer explanation

A scope may be a custom block, a script, or the whole program (all scripts & sprites).

A local variable may be a parameter (local to inside the block) or a script variable (local to the connected blocks in that script).

3.

MULTIPLE CHOICE QUESTION

30 sec • 10 pts

A predicate block will return...

a value of any type

nothing

true or false

a condition

Answer explanation

Media Image

Boolean values true/false are NOT the words true/false. They're their own data type (cf. number, text, sound, etc.).

4.

MULTIPLE CHOICE QUESTION

30 sec • 10 pts

Media Image

Assuming age is a global variable, what will the script say?

50, 60, 50

50, 50, 50

50, 60, 60

50, 50, 60

Answer explanation

There's only one copy of the variable age throughout the entire run of the program.

5.

MULTIPLE CHOICE QUESTION

30 sec • 10 pts

A global variable is

accessible inside only one block in a program

accessible by only one sprite in a program

used as an input parameter

accessible anywhere within the program

6.

MULTIPLE CHOICE QUESTION

30 sec • 10 pts

Media Image

"i" and "branches" are not global variables. What will the script do at "say i for 3 seconds"?

100 for 3 seconds

error

say 8 for 3 seconds

say 9 for 3 seconds

Answer explanation

branches is a parameter, a local variable within the scope of the "draw a pinwheel" procedure. It does not exist outside the block.

7.

MULTIPLE CHOICE QUESTION

30 sec • 10 pts

Media Image

"a" is not a global variable. I will execute script 1. What happens when I execute script 2?

... 3

... 5

error

Nothing - need a hat block first

Answer explanation

a is a local variable within the scope of the script (connected blocks). It doesn't exist in the second script.

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?