-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from ashwani010/computer_nightmare
Computer nightmare
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
# Import 'random' so we can generate random numbers. | ||
import random | ||
|
||
# Initialy the score is 300 | ||
score = 300 | ||
|
||
# List of comments for making the game a more fun! | ||
comments = [ | ||
"** MICROS RULE! **", "*PEOPLE ARE SUPID*", | ||
"+A ROBOT FOR PRESIDENT!", "!COMPUTERS ARE GREAT!", | ||
"*I'M BETTER THAN YOU!*" | ||
] | ||
|
||
# Loop while the score is not above 500 i.e you have won, | ||
# or less than 0 means you have lost the game | ||
while score > 0 and score < 500: | ||
# Number that will be appeared on screen | ||
number = random.randint(1, 9) | ||
print(" %d" % (number)) | ||
print(" %d" % (score)) | ||
|
||
if random.randint(1, 9) > 5: | ||
print(comments[int(score/100)]) | ||
|
||
else: | ||
if score < 60: | ||
print("THERE IS NO HOPE") | ||
elif score > 440: | ||
print("URK! HELP!!") | ||
|
||
print("ENTER THE ANSWER") | ||
answer = int(input()) | ||
# If you have guessed right increase the score | ||
if answer == number: | ||
score = score + number * 2 | ||
|
||
else: | ||
score = score - 10 | ||
|
||
|
||
if score < 0: | ||
print("YOU'RE NOW MY SLAVE") | ||
|
||
else: | ||
print("OKAY! YOU WIN (THIS TIME)") |