Category Archives: python

My python journey (1)

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.

python for beginners

Me and my luck… ๐Ÿ™‚

Posted in python. Tagged with , .