Twenty Questions… well, actually just Two¶
Make a program which plays a simple game of ~~20
~~ 2
Questions.
The first question should be "animal, vegetable, or mineral?"
Then, the second question should be "is it bigger than a breadbox?"
Then, display one of six possible responses, depending on their answers. You can choose what answers to give for each of the six possibilities.
Here’s a suggestion:
animal | vegetable | mineral | |
---|---|---|---|
smaller than a breadbox | squirrel | carrot | paper clip |
bigger than a breadbox | moose | watermelon | Camaro |
You will use nested if
statements to do this.
Name your file: two_questions.py
TWO QUESTIONS!
Think of an object, and I'll try to guess it.
Question 1) Is it animal, vegetable, or mineral?
> animal
Question 2) Is it bigger than a breadbox?
> no
My guess is that you are thinking of a mouse.
TWO QUESTIONS!
Think of an object, and I'll try to guess it.
Question 1) Is it animal, vegetable, or mineral?
> mineral
Question 2) Is it bigger than a breadbox?
> yes
My guess is that you are thinking of a Camaro.
TWO QUESTIONS!
Think of an object, and I'll try to guess it.
Question 1) Is it animal, vegetable, or mineral?
> vegetable
Question 2) Is it bigger than a breadbox?
> yes
You're thinking of a watermelon!
©2021 Daniel Gallo
This assignment is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License.
Adapted for Python from Graham Mitchell’s Programming By Doing