5-1 unplugged (wip)

5-1 Data Variables- unplugged

In this unplugged lesson, students gain knowledge of Variables as they play Madlibs.

OBJECTIVES: By the end of this lesson, students will:

    • assign values to variables.

    • update variables with new values.

TEACHER RESOURCES

Madlibs

Extra Resources: Variables: Code.org

MATERIALS NEEDED

Three envelopes labelled: Animal, Place, Food

5 strips of paper or index cards to fit in envelopes.

concept Data: Variables

TEACHER GUIDANCE:

1. A variable is a container that stores one piece of information at a time. When you store a new value in a variable you overwrite the previously value.

2. Variables can store a number, string or boolean and should have meaningful names, so we can remember what they store.

3. Some common examples of variable use:

      • Number variable: Counter: eg. Timer, Score.

      • String variables: User Input: e.g Answer.

      • Boolean variables: Binary flags: eg. ON/OFF, UP/DOWN, OPEN/CLOSE

Project (15-25 minutes)

Lesson structure:

  1. Explain variables.

  2. Explain and play Madlibs.

Part 1: Explain variables:

Prepare three envelopes and 5 index cards.

Label three envelopes “Animal”, “Place”, “Food”. Inside, place an index card, with a word printed on it. e.g. "cat", "home" or "cookie".

Write a sentence on the board. I am a <Animal>, from <Place> who loves to eat <Food>.

Using Variables.

Bring three students to the front of the room. Give each student an envelope.

The envelopes are the variables and the index cards inside are what are stored in each the variable.

Have students fill in the sentence, substituting the variable name for the the word on the index card.

" I am a cat, from home who loves to eat cookies."

Return index cards to their envelopes.

Updating variables.

Pick a student in the class and give them an index card with the word dog printed on it. Ask them to update the variable "Animal"

They should give the index card to the student holding the envelope "Animal".

This student should delete the old information, ("cat") toss it out of the envelope and replacing it with the new index card with "dog" printed on it. ( It is important to show that only one piece of information can be stored in the envelope one time.)

Create the sentence using the new variable information.

" I am a dog, from home who loves to eat cookies."

Another student should update the variable "Place" with a new Index card with the word "Beach" written on it.

Students should again create the sentence using the new variable information.

" I am a dog from beach who loves to eat cookies."

Why use variables?

Ask students if they can think of a reason why variables may be useful? Yes, it allows you to change the sentence, without rewriting it.

Ask can they think of examples of variables? eg.1. Score in a game. eg.2 When it asks for your Name at the top of a worksheet.

Part 2: Create and play Mad Lib using booklets provided or printables.

      • Student play in small groups, or teachers lead the class, randomly calling on students for their words.

TEACHER GUIDANCE: Students will need guidance on what a noun, verb and adjective are. Student handout 5.2 might be helpful.

An Adjective describes something. E.g. Lumpy, soft, ugly, messy, short.

An Adverb tells how something is done. E.g modestly, greedily, carefully.

A Noun is the name of a person, place or thing. E.g. sidewalk, bathtub, nose.

A Verb is an action word. E.g. run, pitch, jump. swim.

Close-Out (5 minutes)

1. When you play madLibs, you use variables to hold information. Name a variable that you used? Noun, Adjective, Verb.. etc.

When it asked for a noun variable, you substituted the information you stored in "Noun" and put it into your sentence. This made some funny sentences.

2. Can you think of any reasons why variables would also be useful? You do not need to rewrite the entire sentence, just substitute one word.

Yes, variables are efficient and save us time.

TEACHER GUIDANCE:

Variable: a placeholder for a piece of information that can change. Increment: to increase by a specific amount repeatedly. eg: Increment by +1, +2 .. etc. Decrement: to decrease by a specific amount repeatedly. eg. Decrement by -1, -2.. etc.

Standards CSTA

    • CSTA 2-AP-11: Create clearly named variables that represent different data types and perform operations on their values.