What you will learn
- Apply basic Python knowledge about inputs/outputs and variables to create a game of Madlibs
- Practice good debugging skills
Project
Using Python, students will use variables, input, and printing to create a Mad Lib. You will also practice designing a project by planning out your Mad Lib before implementing it. Part of the project is to use your creativity to design your own unique story.
Overview
Mad Libs are a fun way to tell a story. The story is pre-written except for a few missing words. The story is hidden from the user. The user is asked a series of questions in order to fill in the missing words before seeing the story. Then the story is read off with the user’s words mixed in!
Details
Behavior
-
The program will print out the title of the Mad Libs story, as well as a short explanation of game play
A Day in NYC: a Mad Lib. Welcome! You are about to play a fantastic word game. I will ask you for nouns, verbs, adjectives, proper nouns and adverbs. Using those words I will create an unexpected story for you! -
The program should then prompt the user to enter in nouns, verbs, adjectives, proper nouns, and adverbs
Day in New York City: A Mad Lib Instructions. The program will prompt for a type of word to enter. After all words are entered the program will print a story Enter a proper noun: Ariana Grande Enter a place: The Standard Enter another place: Duane Reade Enter an adverb: quickly Enter a noun: donut Enter an adjective: slimy Enter an adverb: foolishly Enter a verb: prance Enter a place: Times Square Enter an adjective: beautiful It was a beautiful day in New York City Our hero Ariana Grande was on a walk from the Standard Duane Reade.Ariana rather than quickly because he/she lived in New York for a few months. Suddenly a slimy donut appeared out of nowhere!!! -
After all the words have been entered. The program will print out the story. You will need to create a story of your own choosing. Keep it clean and fun. Here is an example of a day in New York City.
A Day in NYC: It was a beautiful day in New York City. Our hero Ariana Grande was on a walk from the Standard to Duane Reade. Ariana Grande was walking rather quickly because he/she had lived in New York for a few months. Suddenly, a slimy donut appeared out of nowhere!!! Ariana Grande decided to prance foolishly instead of dealing with the situation. Thrown off from Duane Reade, Ariana Grande decides to go to Times Square instead. What a beautiful day in New York.
Implementation Details
Plan out your story on pencil and paper first, before you start implementing the program.
- Create your story
- Select the missing words
- Determine each words part of speech
- Create introduction
- Create questions
- Divide story into print statements
As mentioned above the program must request words from the user. The following must be included in the program:
- 10 different words inputted
- Variable names should correspond to the part of speech requested and part of the story they belong to (e.g.
noun1,verb2, etc) - You may only use 3 print statements to tell your story
Alternate Project
Created by Brian Weinfeld
Using Python, you will use variables, input, and casting to create a Magic Square.
Overview
Pick a number from 21-65. 42, you say? OK! Check this out!
22 01 12 07
11 08 21 02
05 10 03 24
04 23 06 09
If you add up all the numbers in each row, they total 42. (22 + 1 + 12 + 7 = 11 + 8 + 21 + 2 = 42)
If you add up all the numbers in each column, they total 42. (22 + 11 + 5 + 4 = 1 + 8 + 10 + 23 = 42)
If you add up all the numbers in each diagonal, they total 42. (22 + 8 + 3 + 9 = 7 + 21 + 10 + 4 = 42)
It is the same for each of the four corners, and each 2x2 block as well. (22 + 4 + 9 + 7 = 42)
This is called a Magic Square and for this project, you are going to create a program that lets users select a number and create a magic square from that number.
Details
Behavior
Welcome to Magic Square
Enter a number from 21 to 65: 42
You have entered 42
Here is your Magic Square:
22 01 12 07
11 08 21 02
05 10 03 24
04 23 06 09
Implementation Details
Believe it or not, Magic Squares are not difficult to make! Watch the following video to see how to make a Magic Square for any given number:
Challenge
This section contains additional components you can add to the project. These should only be attempted after the project has been completed.
-
What happens if the user enters a number outside the range of 21-65? Try to check for this and print an error message!
-
What happens if the user doesn’t enter a number at all and enters a word instead? Try to check for this and print an error message!
-
Build a Magic Square with a small number like 22. The Magic Square isn’t aligned properly and hard to read. Try to fix this!
Rubric
Student Name: ___________ Date: ______
Students can correctly use the IDE (1.01)
| 3 | 2 | 1 | 0 | Points |
|---|---|---|---|---|
| Students have correctly used the IDE | - | - | No evidence that the student can use the IDE | |
| Sub Total |
Student can correctly identify and store variable types (1.02, 1.04)
| 3 | 2 | 1 | 0 | Points |
|---|---|---|---|---|
| Student correctly stores variable types | - | Student sometimes stores the correct variable type | No evidence that the student can store correct variable types | |
| Student program asks for input and stores it as a variable | - | Student program asks for input, but does not store it | No evidence that the students can use the input function | |
| Sub Total |
Student can use the print function (1.03)
| 3 | 2 | 1 | 0 | Points |
|---|---|---|---|---|
| - | Students have correctly used the print function | - | No evidence that the students can use the print function | |
| Sub Total |
Student can decompose a problem to create a program from a brief
| 3 | 2 | 1 | 0 | Points |
|---|---|---|---|---|
| Student program runs without error | The students program has a few errors, but it does not impact the program’s functionality | Student program has errors that impact the program’s functionality | Student program is not functional | |
| - | Students submitted documentation showing planning for most variables and functions. | Students submitted documentation showing planning for a few variables and functions. | No evidence of planning | |
| Sub Total |
Student uses naming/ syntax conventions and comments to increase readability
| 3 | 2 | 1 | 0 | Points |
|---|---|---|---|---|
| - | Syntax conventions are generally used | Sometimes syntax conventions are used | No evidence of syntax conventions to aid in code readability | |
| - | All variables have clear names | Some variables have clear names | No evidence of using variable names to aid in code read ability | |
| - | Student comments aid code readability | No evidence of using comments to aid in code readability. | ||
| Sub Total |
Final Grade
| __ 21 ___ | ____ X ____ | ____ |
| Points Possible | Points Earned x Weight | total Points |
Check your understanding
Pick an answer for each question. You can try again until you get it right.
1. Why does a Mad Libs program store each answer in its own variable?
- Because
inputcan only be used once - Because Python forbids printing text directly
- Because variables make the program run faster
- So the words can be reused later when the story is printed
Storing each answer in a variable lets the program combine all the words into the story after collecting them.
2. Which variable name best helps a reader understand the program?
xadjective1thinga1
A descriptive name tells the reader what the variable holds, which makes code easier to read.
3. Why plan a project on paper before coding it?
- Breaking the problem into steps first makes it easier to write and debug
- Python will not run unplanned programs
- Planning replaces testing
- It makes the program print faster
Decomposing a problem into steps before coding gives you a clear path to implement.
