Computer Science Essentials · Do Now · Activity 1.1.4

Who can see it?

Six minutes. Every variable in your apps lives somewhere. Today you find out where — and why it matters when your app breaks.

6:00
1

Sort the variables from YOUR apps

2 min

Tap a chip, then tap a bucket. Everywhere = any block in the app can get or set it. One block only = it exists only inside the handler or procedure it came from.

Everywhere in the app

One block only

2

Same name, two boxes

1 min

App Inventor lets you name a global and a local the same thing. These two set blocks are both called guesses. Which one changes the box the whole app shares?

set global guesses to ( get global guesses − 1 ) set guesses to ( get guesses − 1 )
3

Predict (you can't be sure yet — guess anyway)

2 min

A guessing game starts with GuessesRemaining = 10. The subtract-one block sits at the very top of GuessButton.Click, before any checks. The player taps Guess with the box empty three times, then makes two real wrong guesses. What does the label say?

when GuessButton.Click set global GuessesRemaining to ( get global GuessesRemaining − 1 ) ← at the top if is number? GuessInput.Text then … compare the guess … else set WinLoseLabel.Text to "Pick a number please!"
4

Now the game YOU built

1 min

Two names from your own app. Be exact — the real names you typed.

Brain warmed up.

Global = one box the whole app shares. Any block can read it, any block can change it — which is exactly why bugs in globals are hard to find.

Local = a box that only exists inside the block that made it. Fewer places can touch it, so fewer places to look when it breaks.

Today you build a two-player guessing game with two globals (the secret number and the guesses left) and one local (the guess the player just typed). Then the real job: find the variable in your game that should have been local, and fix it.

Step 3's answer: 5. The blanks got counted. Moving one block is the fix — you'll do it today.