1 of 27

Upper Elementary

Computer Science

Mad Libs Project

2 of 27

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.

3 of 27

Vocabulary

Variable: A container that can hold one value at a time

4 of 27

Vocabulary

List: Allows multiple pieces of information to be stored in a single variable

5 of 27

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

6 of 27

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

7 of 27

What are some lists that you use?

8 of 27

Here are some lists that may be familiar.

Items in your backpack:

  • Books
  • Pencils
  • Erasers
  • Notebooks

Types of fruit:

  • Apples
  • Bananas
  • Oranges
  • Grapes

Colors:

  • Red
  • Orange
  • Blue
  • Purple

9 of 27

What is a “Mad Libs” game?

To play Mad Libs:

  • Write a story.
  • Take out some of the words to the story.
  • The player does not know the story.
  • Ask the player for words (ie. “animal”).
  • Fill in the blank places in your story with the words the player gave you.

hungry

elephant

quickly

red

Jake

popcorn

Words

10 of 27

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

11 of 27

Some sprites and code have been provided for you.

12 of 27

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!

13 of 27

Here’s what a Mad Libs program could look like.

14 of 27

You’ll create a story to program.

Think of a short story. Example prompts:

  • While going to school…
  • While riding a bike…
  • When two friends met to play a sport…

???

15 of 27

Write your story.

  • Write a story with 5 to 9 sentences.
  • The missing words will be the last word in the sentences.

16 of 27

Create the list to hold the words the player will type in.

17 of 27

As you’re coding, remember that you’ll be referring to the numbers next to the words in your list.

18 of 27

Here’s an example of how the list will work.

mop

car

lightbulb

19 of 27

While you’re writing and testing your program, you will leave this visible.

20 of 27

You’ll need to clean up some code.

Clear the list of words each time the game is played.

21 of 27

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”.

22 of 27

Repeat this code for your other sentences.

Ask for the types of words for YOUR story.

23 of 27

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.

24 of 27

Program your first sentence.

25 of 27

You’ll program Devin to read the story with the words the player typed.

26 of 27

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.

27 of 27

Ready for more?

  • Add actions to the sprites.
  • Change backdrop.
  • Add more to your story.