5-2 old

5-2 Mad Libs

Students use variables to store words from user inputs. These words are then output as a crazy MadLib!

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

    • identify reasons to use variables.

    • define a variable of type: string

    • explain string user input : Ask/Answer commands

    • explain string concatenation: Join command.

Do Now Impacts of Computing (5 minutes)

    1. Watch "How Computer Memory Works" [TED-Ed] (5:04)

    2. Discuss:

      • What does the word “bits” stand for? What role do bits play in computers?

      • What other things can you think of that only have two values (on/off, true/false, etc.)

      • What are the different types of memory used by a computer? What are the pluses and minuses of each type of memory/data storage?

TEACHER GUIDANCE:

Mini-Lesson (5-10 minutes)

Students will create 3-5 variables to hold MadLib Information.

In the maze game, students used a variable to store the current Score. ( a number). Today, students will use a variable to store a word (a string).

In Scratch, a variable can be a number, string or boolean value.

Variables Mini Lesson

    • Teacher Prop: a cardboard box or yogurt cup, containing one piece of paper or one scrabbled letter. “A Variable is a container that hold one piece of information at a time." “I think of a variable as being a container, say a cardboard box with a label.""Each container can hold only one item." "The content of the container can change, but the label stays the same.

Act out changing information in the container, but the label stays the same.

Example1 : Container labelled "Letter": Put letter "B" a container. Say "Variable "Letter" contains the letter B"

Take out Letter "B" and put in letter "C" into container. Say "Variable "Letter" now contains the letter C"

Example2 : Container labelled "Score": Put number "3" a container. Say "Variable "Score" contains the Number 3"

Take out number "3" and put in number "5" into container. Say "Variable "Score" now contains the number 5"

Example3: Container labelled "Art Tool" : Put a crayon in container "Art Tools: Say "Variable "Art Tools" contains a crayon".

Take crayon out of container and put a pencil into container. Say "Variable "Variable "Art Tools" now contains a pencil"


Note 1 : Only one piece of information can be assigned to a variable at one time.

Note 2 : Variables can hold different types of information: letter; word; number or boolean.

    • Variables should have meaningful names, to help you remember what is stored.

    • Variable “Score” in the Maze game, held the current score, a number.

    • Variable “Word” will hold a word, a piece of text.

    • Variables in scratch can be global or local or cloud. In this course we use the default "global variable".

    • Global variables allow all sprites to access a variables information. Local variables allow only the sprite where the variable was created to access variable information. A cloud variable saves the variable information in the cloud. This is useful if you want to create a variable across different users such as retaining the highest score for a game.

    • Remind students of the Mad Lib activity they played on the previous day. (Mad Lib, stands for AdLib: unrehearsed improvised acting!)

Lesson overview:

Students make a project where a sprite will speak the Madlib, using user input. See example.

Go over these three main points, before students start project. video

1. Ask/Answer - ask/answer commands reside under sensing. Answer is a built in variable in scratch, that stores the most recent user input.

2. Since we are asking 3-5 questions right after each other, we need to use variables to store the answers. Students should choose meaningful names for their variables.

3. Join command resided under the green operator commands. It is the operator that joins two strings together. Explicitly show that if you want a space, you need to add this space to your string (sentence). When students have omitted the space in their join code, have them re-watch the video starting at 1:40 to allow them to debug their code.

Student Directions:

    1. Use student handout.

      • Make-up a short story of 2 to 3 sentences.

      • Underline 3-5 words, and think of a meaningful generic variable name of this type of word. (Page 1: handout)

    2. Log in to Scratch classroom. Create a Scratch project and share it with your teacher.

    3. Using student handout, ask for 3-5 words, and have a sprite speak them back in a MadLib.

    4. Save work and add to classroom studio.

TEACHER GUIDANCE:

Project (20-30 minutes)

Close-Out (5 minutes)

    1. Discuss the following questions:

        • Variables are containers that store data.

        • Variables can hold: numbers (e.g. Score); strings (e.g. Answers); booleans (e.g. TRUE/FALSE).

        • Variables can only hold one thing at a time.

        • Variables should be named meaningful, so that what they contain can be remembered.

TEACHER GUIDANCE:

Standards CSTA

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

    • CSTA 2-AP-13: Decompose problems and subproblems into parts to facilitate the design, implementation, and review of programs.