Skip to content

Commit

Permalink
Clean up some recent examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
freakboy3742 committed Jan 2, 2018
1 parent 89097f3 commit beb5275
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 51 deletions.
Original file line number Diff line number Diff line change
@@ -1,50 +1,38 @@
# Import 'random' so we can generate random numbers.
# The 'string' module gives us access to string-related utilities
# The 'time' module helps us to wait for some time


import random
import string
import time
print("VITAL MESSAGE")

print('VITAL MESSAGE')

# Variable to store the difficulty i.e length of string
level_difficulty = 0
difficulty = 0

# Loop until the right difficulty level is enterred
while level_difficulty < 4 or level_difficulty > 10:
print("HOW DIFFICULT? (4-10)")
while difficulty < 4 or difficulty > 10:
print('How difficult do you want the game to be? (4-10)')
x = int(input())
level_difficulty = x

# Function to clear the screen
# This simply clears the screen by printing 64 blank lines


def clrsc():
print('\n' * 64)


# Variable to store the secret message
message = ""
difficulty = x

for i in range(0, level_difficulty):
message += (random.choice(string.ascii_letters))
# Create the secret message
message = ''.join(
random.choice(string.ascii_letters)
for i in range(0, difficulty)
)

print("SEND THIS MESSAGE:")
print('Send this message:')
print(message)

# Displaying the secret message in accordance of the difficulty level
time.sleep(0.5 * level_difficulty)
clrsc()
# Display the secret message in accordance with the difficulty level
time.sleep(0.5 * difficulty)

print("Enter the secret code that need to be transferred")
code = input()
code = input('Enter the secret code that need to be transferred')

if(code == message):
print("MESSAGE CORRECT")
print("THE WAR IS OVER")
if code == message:
print('MESSAGE CORRECT')
print('The war is over!')
else:
print("YOU GOT IT WRONG")
print("YOU SHOULD HAVE SENT:")
print(message)
print('YOU GOT IT WRONG')
print('You should have sent:', message)
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Import 'random' so we can generate random numbers.
import random

Expand All @@ -7,40 +6,40 @@

# 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!*"
]
'** MICROS RULE! **',
'*PEOPLE ARE SUPID*',
'+A ROBOT FOR PRESIDENT!',
'!COMPUTERS ARE GREAT!',
'I AM BETTER THAN YOU!',
]

# Print a heading
print(' Number Score')
print('~~~~~~~~~~~~~~~~')

# 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 that will appear on screen
number = random.randint(1, 9)
print(" %d" % (number))
print(" %d" % (score))
print(' %4d %4d' % (number, score))

if random.randint(1, 9) > 5:
if random.random() > 0.5:
print(comments[int(score/100)])

else:
if score < 60:
print("THERE IS NO HOPE")
print('THERE IS NO HOPE')
elif score > 440:
print("URK! HELP!!")
print('URK! HELP!!')

print("ENTER THE ANSWER")
answer = int(input())
answer = int(input('Enter your guess:'))
# 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")

print('YOU ARE NOW MY SLAVE')
else:
print("OKAY! YOU WIN (THIS TIME)")
print('OK... you win... (this time)')

0 comments on commit beb5275

Please sign in to comment.