Search Header Logo
Variables Explore

Variables Explore

Assessment

Presentation

Computers

12th Grade

Practice Problem

Easy

Created by

Katherine Valenti

Used 5+ times

FREE Resource

26 Slides • 9 Questions

1

media
media

Unit 4 - Lesson 1
Variables Explore

Computer Science Principles

2

media

3

media
media
media

Unit 4 Lesson 1 - Warm Up

Do This:
Navigate to Lesson 1,

Levels 3-5 on Code Studio

4

Open Ended

These are samples of the kinds of apps you'll be able to build by the end of this unit. Write down at least two examples where the apps seems to be keeping track of a piece of information or using it to make decisions.

5

Warm Up

  • Last unit we built apps that mostly focus on input and output

    • When button is clicked --> show picture

    • When button is clicked --> change screen

    • When button is clicked --> play a sound

  • In this unit, we are going to build apps to keep track of information and use that information to make decisions and perform calculations

6

Warm Up

  • The Pet Rock App keeps track of clicks and uses it to decide when the pet rock will "evolve"

  • The Poem App keeps track of the poem as you write it

  • The Thermostat App keeps track of temperature and uses it to change the color of the text

7

media

8

media

“hi”

“hi there”

“c u l8r

Strings
Made of any characters
Inside double quotes

548

Numbers
Made of the digits 0...9
No quotes

Value

One piece of information

Goes on a sticky

“123”

Unit 4 Lesson 1 - Activity

9

22

123

media

9

Open Ended

Give an example of one string and one number.

10

media

2

3

Operators
Fancy name for + - * /

Expression
Combination of operators and values
Evaluates to single value

+


evaluates to

1

-

Unit 4 Lesson 1 - Activity

5

11

media

3

4
evaluates to
+

7

5

2
evaluates to
-

3

“for”

“ever”
evaluates to
+

“forever”

“gr”

8
evaluates to
+
“gr8”

2

“day”
evaluates to
+
“2day”

4

5

+

10

9

-

“tree”

“house”

+

“you”

“r”

+

3

“D”

+

11

2
evaluates to
*

22

10

2
evaluates to
/

5

Unit 4 Lesson 1 - Activity

9

1

"treehouse"

“your”

“3D”

media

12

Open Ended

Question image

Evaluate these expressions

13

media

3

4
evaluates to
+

7

5

2
evaluates to
-

3

“for”

“ever”
evaluates to
+

“forever”

“gr”

8
evaluates to
+
“gr8”

2

“day”
evaluates to
+
“2day”

4

5

+

10

9

-

“tree”

“house”

+

“you”

“r”

+

3

“D”

+

11

2
evaluates to
*

22

10

2
evaluates to
/

5

Unit 4 Lesson 1 - Activity

9

1

"treehouse"

“your”

“3D”

media

14

media

woop

2

zip

“hi”

Variables

Plastic baggies

Can hold at most one value

Name uses no quotes,
includes no spaces, and
must start with a letter

zip2

Unit 4 Lesson 1 - Activity

15

Open Ended

Give an example of a variable name

16

media

bop

zip
5

“hi”

3

bop + zip

“hi5”
evaluates to
“hi”

+

5

+ zip

Make a copy of the
value in zip. Don’t take
the sticky out of zip.

Unit 4 Lesson 1 - Activity

media

17

Open Ended

Question image

Evaluate these expressions. Make sure you pay attention to whether it evaluates to a string or a number.

18

media

3

4
evaluates to
+

7

5

2
evaluates to
-

3

“for”

“ever”
evaluates to
+

“forever”

“gr”

8
evaluates to
+
“gr8”

2

“day”
evaluates to
+
“2day”

4

5

+

10

9

-

“tree”

“house”

+

“you”

“r”

+

3

“D”

+

11

2
evaluates to
*

22

10

2
evaluates to
/

5

Unit 4 Lesson 1 - Activity

9

1

"treehouse"

“your”

“3D”

media

19

media

pow

var
Creates a new variable
Grab a new baggie
Writes the variable’s name on the baggie

00 var pow

Command to
create variable

Variable’s name

Line number

Unit 4 Lesson 1 - Activity

20

media
media

00 var pow

01 pow 3

02 pow 5

pow

pow

pow

3

5

3

Unit 4 Lesson 1 - Activity

media

21

Open Ended

Question image

Run this program. What would be stored in the pizza and tacos variables?

22

media

3

4
evaluates to
+

7

5

2
evaluates to
-

3

“for”

“ever”
evaluates to
+

“forever”

“gr”

8
evaluates to
+
“gr8”

2

“day”
evaluates to
+
“2day”

4

5

+

10

9

-

“tree”

“house”

+

“you”

“r”

+

3

“D”

+

11

2
evaluates to
*

22

10

2
evaluates to
/

5

Unit 4 Lesson 1 - Activity

9

1

"treehouse"

“your”

“3D”

media

23

media
media

00 var pow

02 pow 3 + 4

pow

pow

pow

3

7

3

Evaluate expression first

Unit 4 Lesson 1 - Activity

media

24

Open Ended

Question image

Run this program. What would be stored in the fly and zow variables?

25

media

3

4
evaluates to
+

7

5

2
evaluates to
-

3

“for”

“ever”
evaluates to
+

“forever”

“gr”

8
evaluates to
+
“gr8”

2

“day”
evaluates to
+
“2day”

4

5

+

10

9

-

“tree”

“house”

+

“you”

“r”

+

3

“D”

+

11

2
evaluates to
*

22

10

2
evaluates to
/

5

Unit 4 Lesson 1 - Activity

9

1

"treehouse"

“your”

“3D”

media

26

media
media

kit

kit

boo

kit

boo
1

2

00 var kit

01 kit 1

02 var boo

03 boo kit + 1

04 kit 5

kit

1

1

kit

boo
5

2

1

Note: Variables aren’t
“connected”. Changing kit
doesn’t change boo.

Unit 4 Lesson 1 - Activity

media

27

Open Ended

Question image

Run this program. What would be stored in the fuzz and clip variables?

28

media

3

4
evaluates to
+

7

5

2
evaluates to
-

3

“for”

“ever”
evaluates to
+

“forever”

“gr”

8
evaluates to
+
“gr8”

2

“day”
evaluates to
+
“2day”

4

5

+

10

9

-

“tree”

“house”

+

“you”

“r”

+

3

“D”

+

11

2
evaluates to
*

22

10

2
evaluates to
/

5

Unit 4 Lesson 1 - Activity

9

1

"treehouse"

“your”

“3D”

media

29

media
media

pow

pow

pow

Numbers and strings are two different types of values

Expressions evaluate to a single new value

When variables are in the expression just make a
copy, don’t change the actual variable.

Variables are “assigned” a new value

Evaluate first, then assign

Old values are deleted forever.

Assignment just moves information around. It does
not “connect” variables.

“hi”

22

10

2
evaluates to
/

5

00 var pow

01 pow 1 + 2

02 pow 3 + 4

3

7

3

Unit 4 Lesson 1 - Activity

media

30

media

In some languages (including Javascript)

the assignment operator is not written as

it is written as

=

Unit 4 Lesson 1 - Activity

31

media

fuzz fuzz + 1

it is written as

fuzz = fuzz + 1

In math = means “are equal forever”

We’ll see this more next time.

Unit 4 Lesson 1 - Activity

media

32

media

33

media

Expression: a combination of operators and values that evaluates to a single value

Variable: holds one value at a time

Assignment Operator: allows a program to change the value represented by a variable

Unit 4 Lesson 1 - Wrap Up

01 pow 1 + 2

pow

3

OR =

34

Multiple Choice

Question image

What will the value of score be at the end of the program?

1

1

2

The score is: 4

3

4

4

The score is: score

35

Wrap Up

  • Create score variable

  • score is 3

  • score is 4

  • score is The score is: 4

media
media
media

Unit 4 - Lesson 1
Variables Explore

Computer Science Principles

Show answer

Auto Play

Slide 1 / 35

SLIDE