Upper Elementary
Computer Science
Mad Libs Project
Objective
Students will be able to use lists in a program to create a Mad Libs game.
Computational Thinking: Algorithmic thinking is organizing a process into clear, step-by-step instructions.
Vocabulary
Variable: A container that can hold one value at a time
Vocabulary
List: Allows multiple pieces of information to be stored in a single variable
How does a variable work?
Think of a variable as a cup. We can call it a “cup”, and it holds one thing at a time, such as water, or milk, or juice.
Cup
How does a list work?
Think of a list like a “loot box” in a game. It’s called “loot box”, and holds a group of things that are related, but different, such as a wand, and a cloak, and a magic potion.
Loot Box
What are some lists that you use?
Here are some lists that may be familiar.
Items in your backpack:
Types of fruit:
Colors:
What is a “Mad Libs” game?
To play Mad Libs:
hungry
elephant
quickly
red
Jake
popcorn
Words
How will you create the game?
You’ll be using “lists” in your program to save a group of words to use in your Mad Libs game.
hungry
elephant
quickly
red
Jake
popcorn
Words
Some sprites and code have been provided for you.
You’ll create the list and the story!
Your finished code will look something like this.
Don’t worry… we’ll decompose it to write it step by step!
Here’s what a Mad Libs program could look like.
You’ll create a story to program.
Think of a short story. Example prompts:
???
Write your story.
Create the list to hold the words the player will type in.
As you’re coding, remember that you’ll be referring to the numbers next to the words in your list.
Here’s an example of how the list will work.
mop
car
lightbulb
While you’re writing and testing your program, you will leave this visible.
You’ll need to clean up some code.
Clear the list of words each time the game is played.
Program Scout to ask the player to type the first word for your story.
Ask for the type of word for your first sentence.
Add a “broadcast message”.
Repeat this code for your other sentences.
Ask for the types of words for YOUR story.
You’ll be combining these code blocks to create the sentences of your story.
This is the number in the list that you want to use.
Program your first sentence.
You’ll program Devin to read the story with the words the player typed.
Finish programming Devin to read the story.
Repeat the “next costume” and “say” code blocks for each sentence in your story. These will go before the “broadcast message” code block.
Ready for more?