Skip to content

Instantly share code, notes, and snippets.

@gkalemis
Created June 15, 2018 15:20
Show Gist options
  • Save gkalemis/5a79f52ab3f7ff82cf343997475c44a6 to your computer and use it in GitHub Desktop.
Save gkalemis/5a79f52ab3f7ff82cf343997475c44a6 to your computer and use it in GitHub Desktop.
Fortune Teller final
'''
This is a Fortune Teller computer program
It uses two functions that are combined to work together
'''
import random
def getAnswer(answerNumber):
'''Return a answer based on a number input from 1 to 9
Args:
answerNumber (int) : The variable of the function
'''
if answerNumber == 1:
return 'It is certain'
elif answerNumber == 2:
return 'It is decidedly so'
elif answerNumber == 3:
return 'Yes'
elif answerNumber == 4:
return 'Reply hazy try again'
elif answerNumber == 5:
return 'Ask again later'
elif answerNumber == 6:
return 'Concentrate and ask again'
elif answerNumber == 7:
return 'My reply is no'
elif answerNumber == 8:
return 'Outlook not so good'
elif answerNumber == 9:
return 'Very doubtful'
def adviseMe(question):
'''Prints a answer that is returned from getAnswer function
based on a random number from 1 to 9
Args:
question (str) : The variable of the function
'''
r = random.randint(1,9)
fortune = getAnswer(r)
print ("You asked : " + question)
print ("My answer is : ", end ="")
print (fortune)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment