

Variables Explore
Presentation
•
Computers
•
12th Grade
•
Practice Problem
•
Easy
Katherine Valenti
Used 5+ times
FREE Resource
26 Slides • 9 Questions
1
Unit 4 - Lesson 1
Variables Explore
Computer Science Principles
2
3
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
8
“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
9
Open Ended
Give an example of one string and one number.
10
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
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”
12
Open Ended
Evaluate these expressions
13
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”
14
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
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
17
Open Ended
Evaluate these expressions. Make sure you pay attention to whether it evaluates to a string or a number.
18
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”
19
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
00 var pow
01 pow ← 3
02 pow ← 5
pow
pow
pow
3
5
3
Unit 4 Lesson 1 - Activity
21
Open Ended
Run this program. What would be stored in the pizza and tacos variables?
22
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”
23
00 var pow
02 pow ← 3 + 4
pow
pow
pow
3
7
3
Evaluate expression first
Unit 4 Lesson 1 - Activity
24
Open Ended
Run this program. What would be stored in the fly and zow variables?
25
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”
26
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
27
Open Ended
Run this program. What would be stored in the fuzz and clip variables?
28
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”
29
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
30
In some languages (including Javascript)
the assignment operator is not written as
←
it is written as
=
Unit 4 Lesson 1 - Activity
31
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
32
33
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
What will the value of score be at the end of the program?
1
The score is: 4
4
The score is: score
35
Wrap Up
Create score variable
score is 3
score is 4
score is The score is: 4
Unit 4 - Lesson 1
Variables Explore
Computer Science Principles
Show answer
Auto Play
Slide 1 / 35
SLIDE
Similar Resources on Wayground
31 questions
Module 4 / Unit 3 (ITCC103-102I)
Presentation
•
University
26 questions
PROGRAMMING-ARRAY
Presentation
•
12th Grade
28 questions
Folding Activity
Presentation
•
12th Grade
32 questions
Sorting Algorithm
Presentation
•
12th Grade
30 questions
Senderos 1 Estructura 2.1 Present tense of -ar verbs
Presentation
•
12th Grade
25 questions
01 Python Basics
Presentation
•
University
29 questions
App Dev Proj Week 1 Lesson 2
Presentation
•
12th Grade
25 questions
Physical and Chemical Changes Review
Presentation
•
8th Grade
Popular Resources on Wayground
24 questions
PBIS-HGMS Day 10
Quiz
•
6th - 8th Grade
10 questions
HCS SCI 03 Summer School Review 3
Quiz
•
3rd Grade
11 questions
Home Scope
Quiz
•
7th - 8th Grade
15 questions
HCS SCI 05 Summer School Assessment 3 Review
Quiz
•
5th Grade
35 questions
Lufkin Road Middle School Student Handbook & Policies Assessment
Quiz
•
7th Grade
18 questions
Geo 11.3 Area of Circles and Sectors
Quiz
•
9th - 11th Grade