So I’m trying to learn python using “Python for the absolute beginner, 3rd edition”
Challenges:
. Write a program that simulates a fortune cookie. The program
should display one of five unique fortunes, at random, each
time itโs run.
# program to display fortune cookies # display random one of 5 fortune cookies import random cookie = int(random.randint(1, 5)) if cookie == 1: print(cookie, "it is.", "You will win the lottery this week.") elif cookie == 2: print(cookie, "it is.", "You will get laid with a hot blonde...someday.") elif cookie == 3: print(cookie, "it is.", "You will get an extra hour of sleep.") elif cookie == 4: print(cookie, "it is.", "You will be a successful hacker.") elif cookie == 5: print(cookie, "it is.", "Nothing special will happen today. Tough luck!") else: print("Error happend") input("\nPress enter to exit!")
And here is the output of the program.
Leave a Reply