U4Ch1L1_Variables Explore
Purpose: Students will acquire an understanding of how variables work.
Gradesheet!
Vocabulary: Variables, Values, Number, Strings, Operators, Expression, Evaluate
(Write on front board...have student take a guess.)
Activity: Log on to Code.org U4Ch1L1 _ Explore Variables
Explore Sample Apps: Ask students to play with the following 3 Apps and to be able to explain the difference between these Apps and the ones they used in Unit 3. - (The difference is that these Apps are more sophisticated. These Apps keep track of information, track information, make decisions and perform calculations!)
- The Pet Rock (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.
Activity: Variables (match students with a partner.)
1. Values – The most basic unit of data ia a value - made up of Numbers and Strings.
2. Operator – Plus, Minus, Multiply and divide symbols.
Do This: Have students take another colored Sticky, tear it in 4 for the operators - Note "=" can be on a 4th colored Sticky.
Do This: Evaluate this Expression: 5-1 and write on Sticky?
3. Using Expressions
Do This: Evaluate the following Expressions:
4. Create A Variable - Think of a computer Variable as a container.
Do This:
- Create 3 variables and write them on the 3 baggies.
- Create a String, write it on a Sticky and place inside one of the baggies/variables.
- Create a Number, write it on a Sticky and place inside one of the other baggies/variables.
5. Variables & Expressions
- Write Your Answers on handout.
- Compare your results with the Other Students!
- Answer
Do This #1: Create an Expression with the Number Sticky and Variable and Evaluate.
Create an Expression with a Variable and String and Evaluate.
Create an Expression with a Variable and a Variable and Evaluate.Now, solve this problem:
- Write Your Answers on handout.
- Compare your results with the Other Students!
- Answer
6. Lets Start Writing Programs with Variables – Note: <- equals =
Note: In math = means "are equal forever". In programming = means "put this value in this variable"
Line Number |
Command To Create Variable |
Variable Name |
00 |
var |
pow |
Take a look at how a Variable can only have one Value.
Do This: Run This Program:
7. Assign a Variable with Expression
Take a look at how you can assign values to Variables by Evaluating and Expression.
8. Assign a Variable: Expression with Variables
Do This: Run This Program:
Do This: Run This Program: