Skip to content

Instantly share code, notes, and snippets.

@sdawncasey
Created November 30, 2013 18:47
Show Gist options
  • Save sdawncasey/7722901 to your computer and use it in GitHub Desktop.
Save sdawncasey/7722901 to your computer and use it in GitHub Desktop.
This is my first attempt to write a Python program that would take inputs and return a final result based on the values of the original responses. I'm a complete newbie and have only gone through the first 13 chapters of "Hello, World" by Sande (at this point). It's not pretty, but it works! :)
import time
print "This is a fortune teller. You will enter some information,"
print "and I will tell you your fortune."
time.sleep(1)
name = raw_input("What is your name? ")
print "Hi,",name, "let's get started with the questions."
time.sleep(1)
print "Okay."
time.sleep(1)
print "You will be asked four questions about yourself and each answer will be scored."
time.sleep(2)
print "Your score determines your fortune!"
time.sleep(2)
#The first three questions will be scored according to the number of characters in the answer.
first = raw_input("Give a short description of yourself. What are you like? Say as much as you like.")
first_score = len(first)
if first_score > 50:
second = raw_input("Wow. You've got a lot to say. Can you sum it up in one word?")
elif first_score < 50:
second = raw_input("Not very talkative, eh? Can you sum yourself up in one word?")
second_score = len(second)
time.sleep(1)
third = raw_input("What is your favorite place to be?")
third_score = len(third)
time.sleep(1)
print "One last question and then I'll tell you your fortune."
time.sleep(1)
#the fourth question is biased towards people that like cats better than dogs.
fourth = raw_input("Are you a cat person, or a dog person?")
if fourth == "cat" or fourth == "cat person":
fourth_score = 10
elif fourth == "dog" or fourth == "dog person":
fourth_score = 5
else:
fourth_score = 0
total_score = first_score + second_score + third_score + fourth_score
time.sleep(1)
print "Okay ", name,"!"
time.sleep(1)
print "Your answers gave you a score of", total_score
time.sleep(1)
print "Therefore, your fortune is..."
time.sleep(2)
#this function takes the total_score, evaluates it, and returns the proper fortune.
def fortune(total_score):
if 0 <= total_score <= 10 :
print "A diamond is a piece of coal that stuck with the job."
elif 11 <= total_score <= 30:
print "A friend is someone who knows the song in your heart,"
print "and can sing it back to you when you have forgotten the words."
elif 31 <= total_score <= 50:
print "It is a good time to start something new."
elif 51 <= total_score <= 80:
print "A pleasant surprise is in store for you."
elif 81 <= total_score <=110:
print "Alone we can do little, together we can do so much."
elif 111 <= total_score <=140:
print "An unexpected event soon will bring you happiness."
elif total_score <= 141:
print "Be what you wish others to become."
fortune(total_score)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment