Created
December 10, 2013 03:49
-
-
Save cdarringer/7885462 to your computer and use it in GitHub Desktop.
My daughter's first experiment with python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""The Animal Guessing Game | |
dichotomous keys and python | |
author: Frances Darringer, age 9 | |
""" | |
def main(): | |
print "Hello, and welcome to the animal guess game!" | |
print "In this game, I will give you a list of 7 animals. They are: " | |
print "(1) Panda" | |
print "(2) Dolphin " | |
print "(3) Shark " | |
print "(4) Cheetah " | |
print "(5) bat " | |
print "(6) hedgehog " | |
print "(7) bumblebee " | |
print "Now pick one of these animals, but do not tell anyone which animal you picked! don't even click on it!" | |
raw_input("Are you ready? Press return to continue...") | |
if checkAnswer("Is your animal a land animal?"): | |
if checkAnswer("Is your animal white and/or black?"): | |
if checkAnswer("does your animal fly?"): | |
print " IT IS A BAT!" | |
else: | |
print "IT IS A PANDA!" | |
else: | |
if checkAnswer("is your animal prickly?"): | |
print "IT IS A HEDGEHOG!" | |
else: | |
print "IT IS A BUMBLEBEE" | |
else: | |
if checkAnswer("Does your animal start with the letter D?"): | |
print "IT IS A DOLPHIN!" | |
else: | |
print "IT IS A SHARK!" | |
def checkAnswer(question): | |
answer = raw_input(question) | |
answer = answer.lower() | |
while answer not in ['y', 'n', 'yes', 'no']: | |
print "Sorry, but I do not know what you wrote. Please try again." | |
answer = raw_input(question) | |
answer = answer.lower() | |
if answer in ['y', 'yes']: | |
return 1 | |
else: | |
return 0 | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment