Skip to content

Instantly share code, notes, and snippets.

@seanballais
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seanballais/86a6f18fdd6f2588eea8 to your computer and use it in GitHub Desktop.
Save seanballais/86a6f18fdd6f2588eea8 to your computer and use it in GitHub Desktop.
def main():
numberOfBottles = 99
while numberOfBottles != 0:
firstVerseLine = getFirstOrLastLine(numberOfBottles)
print(firstVerseLine)
print(firstVerseLine + ", take one down pass it around.")
numberOfBottles = numberOfBottles - 1
lastVerseLine = getFirstOrLastLine(numberOfBottles)
print(lastVerseLine + "\n")
def getFirstOrLastLine(numberOfBottles):
bottleQuantity = "bottle"
if numberOfBottles > 1 or numberOfBottles == 0:
bottleQuantity = "bottles"
verseLine = str(numberOfBottles) + " " + str(bottleQuantity) + " of beer on the wall"
return verseLine
if __name__ == "__main__":
main()
import random, time
responses = [
"No.", "Yes.", "Maybe.", "Time will explain.", "Be patient.",
"Maybe not.", "I am not sure", "In the future.", "Time will tell.", "Hmmm...",
"The vision is cloudy.", "Check back next time.", "I shouldn't probably say.", "Uhhhh...", "Meh!",
"Most likely.", "Unlikely.", "Your future self says yes.", "Your future self says no.", "You must look for an answer on your own."
]
execute = True
print("Magic 8 Ball by Sean Francis N. Ballais")
while execute:
question = input("Question: ")
print("Thinking...")
time.sleep(2.1)
index = random.randrange(0, 19)
print("Response: " + responses[index])
again = input("Press ENTER for another question, or press 'Q' to exit. ")
if (again != ""):
execute = False
print("Thank you for using Magic 8 Ball.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment