You are on page 1of 3

CSP U4L2 Variables Investigate Activity Guide

Directions: Use this activity guide to record your thoughts and responses to the prompts, all
marked by bullet points below.

Level 2
● How does the app work?
You run the app and click the down or up arrow button to increase or
decrease the number of temperatures.
● What are the variables?
○ What is being stored?
The variables are temp to make the watchers work.
○ What is being changed?
On event variable was added
____________________________________________________________
Level 3
Complete the following prompts for both sections of code
Lines 1-12
● Explain what the section does
Create variables and place numbers on the screen.
● Call out any lines of code you thought were interesting or confusing
After a while I was able to understand all the code.

Lines 13-35
● Explain what the section does
It increases the temperature or decreases it by clicking on buttons.
● Call out any lines of code you thought were interesting or confusing
● How do you think Math.round works?
Rounds to the nearest integer
● Try deleting Math.round in lines 3, 15, and 28. What happens? Add it back in.
The number after the decimal becomes extremely long and fills the screen
● Delete the space in between the quotation marks and the letter "F" in line 4.
How does this change what is displayed on the screen?The space between
the number and F is eliminated, and they are combined.
____________________________________________________________
Level 4
● What new information is being stored?
The name of the user can be imputed.
____________________________________________________________
Level 5
Investigate the code for this new version of the Thermostat App.
CSP U4L2 Variables Investigate Activity Guide
● What code has been changed?
Previously, it was temp + "F," but it is now tempF + 1
● What code has been added?
A new home screen has been created where your name is requested. After your name,
there is an exclamation point.
● What's happening on line 40? Hover over the getText() block in the toolbox
to read its documentation.
two texts are being together.
● Using concatenation, add an exclamation point "!" to the end of the string
stored in userName so the following is displayed:

____________________________________________________________
Counter Pattern with Event
The Counter Pattern with Event is a common pattern for updating variables that you will use in
making many different apps. Look over the Counter Pattern with Event example.

● The “Counter Pattern with Event” should look familiar! How would you
explain this pattern to another person? Make sure you step through each
line of the pattern.
A program where you can change the variables.
● When might you want to use the “Counter Pattern with Event”?
to update variables you'll use to create a variety of apps.
____________________________________________________________
Variable with String Concatenation
Variables can store many different types of information including numbers and Strings.
Anything placed inside of the quotation marks becomes a String. Guess what! There's a pattern
for working with Strings. When we want to combine Strings with other Strings, numbers, or
even with another variable we call that concatenation. Look over the Variable with String
Concatenation example.

● Type out how you would explain to a classmate how the “Variable with
String Concatenation Pattern” works. Make sure you step through each
line of the pattern
CSP U4L2 Variables Investigate Activity Guide
Combining two strings, a number, or a string, such as "high" 5 —> "High5"

You might also like