5.2 Mad Libs

Students create a story by asking for two questions and using the answers in a story. Answer words are stored in variables.
Students choose a general label for a specific word - Abstraction in action. Prerequisite is Unit 4.3 - ask/answer commands.

OBJECTIVES:




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

    • give generic label for a word in story (abstraction).

    • create variables to store user input.

    • observe that your MadLibs can make sentences, using different variable input.

TEACHER RESOURCES:

Standards

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

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

CSTA

DO NOW:

Do Now Digital Citizenship (5 minutes)

  1. Watch Privacy (1:45) What you do online can be see, copied and passed on.

      • Can you delete what you do online or is it permanent?

      • Given these facts, how will you express yourself online, whilst protecting yourself online?

Teacher Guidance

  • Even if you are able to get your original post deleted, it may already have been copied and passed on. It is very difficult to get things permanently deleted from the internet.

Mini-Lesson (5-10 minutes)

Mini-Lesson (5-10 minutes)

1. Show Madlib Project that students will build today.
Notice that we ask two questions before making the sentence. Ask/Answer combo saves the last user input into Answer. To save both user inputs, we need to save the answers in variables. Show Ask/Answer Video.

2. Story Creation: Model using the story handout, which asks student to create 2/3 short sentences and circle 2/3 words.

Abstraction: Think of generalized labels for the words circled.


Pulling out a specific word and replacing it with a general label allows your sentence to work with a wide variety of responses!


Students should create a short story or use lyrics from a song. Extract 2/3 words and label each word with a generic name.


3. Demonstrate Madlib Project. What steps do you think are needed to build this game?

  • Ask question and save answer in a variable.

  • Ask second question and save answer in another variable

  • Use join command to speak the story.

  • If needed, review how to create a variable and how to use multiple join commands.

Project (20-30 minutes)

Students start working on the project,

TEACHER GUIDANCE:
Variables can store numbers (e.g score, 4-4), boolean states (eg on/off, 5-2) and text (words, 5-4).
Students used abstraction to pull a specific word from a sentence and replace it with a general name. Abstraction is a key computer science concept as it allows simplification of complex systems.

Close-Out (5 minutes)

Close-Out (5 minutes)

Discuss the following questions:

1. Why did you need to store the user input in a variable?

Answer only retains the last user response, so if you want to store two answers you need a variable.

2. Did you name your variable(s) descriptively? Why is this important? So you can remember what you stored and others can easily read your code.

3. Did you notice that when you used a variable to store a word, you could make endless versions of your story?

This made the story fun! It is also is a powerful idea, known as Abstraction which reduces complexity and increases efficiency.

Potential Responses

  1. Abstraction is a conceptual process where general rules and concepts are derived from the usage of specific examples.

  2. In computer science, abstraction is used to reduce system complexity and gain efficiency.