Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2c4fddc

Browse files
committed
added magic 8 ball
1 parent aaaae62 commit 2c4fddc

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

‎magic_8_ball.py‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# magic_8_ball.py
2+
3+
# Give the all knowing ball a shake
4+
5+
import random
6+
import time
7+
8+
print("### MAGIC 8 BALL ###")
9+
10+
def shake():
11+
# Generate random num btw 0 & 8.
12+
r = random.randint(0, 8)
13+
print(" . . . Shaking . . . ")
14+
# List of possible fortunes.
15+
fortune_list = ["It is certain",
16+
"It is decidedly so",
17+
"Yes",
18+
"Reply hazy try again",
19+
"Ask again later",
20+
"Concentrate and try again",
21+
"My reply is no",
22+
"Outlook not so good",
23+
"Very doubtful" ]
24+
25+
time.sleep(5) # Add some suspense
26+
return fortune_list[r] # Return reply
27+
28+
29+
print( shake() )

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /