
Description :-
The game is simple a random number is chosen by this program every time and you have to guess it right If the number is less than what you guessed it will say "Too high guess" else "Too low" and if your guess is correct then you are the inner.The number will be between 1 and 100 and you will get 5 chances to guess it correctly.
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
import random | |
title = ''' | |
_____ _ _____ ____ ____ _____ _ _____ | |
/ __// \ /\/ __// ___\/ ___\ /__ __\/ \ /|/ __/ | |
| | _| | ||| \ | \| \ / \ | |_||| \ | |
| |_//| \_/|| /_ \___ |\___ | | | | | ||| /_ | |
\____\\____/\____\\____/\____/ \_/ \_/ \|\____\ | |
_ _ _ ____ _____ ____ | |
/ \ /|/ \ /\/ \__/|/ _ \/ __// __\ | |
| |\ ||| | ||| |\/||| | //| \ | \/| | |
| | \||| \_/|| | ||| |_\\| /_ | / | |
\_/ \|\____/\_/ \|\____/\____\\_/\_\ | |
By Psycho_Coder @rawCoders | |
''' | |
def description(): | |
print("""The game is simple a random number is chosen by this program everytime and you have to guess it right | |
If the number is less than what you guessed it will say "Too high guess" else "Too low" and if your | |
guess is correct then you are the winner.The number will be between 1 and 100 and you will get 5 chances | |
to guess it correctly""") | |
def getRandomNum(): | |
return random.randint(1, 100) | |
def game(): | |
count = 0 | |
MAX_NO_OF_GUESS = 5 | |
num = getRandomNum() | |
guess = 0 | |
while count < MAX_NO_OF_GUESS: | |
count += 1 | |
print("\nEnter Your Guess :") | |
guess = int(input()) | |
#guess = int(guess) | |
if guess < num: | |
print("You guessed the number too low") | |
elif guess > num: | |
print("You guessed the number too High") | |
else: | |
break | |
if guess == num: | |
print("Congratulations! You guessed the number correctly.") | |
print("You Guessed the number correctly in " + str(count) + " steps") | |
if guess != num: | |
print("Aww! You Ran out of your chances.") | |
print("The Correct answer would have been :", str(num)) | |
if __name__ == "__main__": | |
print(title) | |
description() | |
game() |
Output
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
_____ _ _____ ____ ____ _____ _ _____ | |
/ __// \ /\/ __// ___\/ ___\ /__ __\/ \ /|/ __/ | |
| | _| | ||| \ | \| \ / \ | |_||| \ | |
| |_//| \_/|| /_ \___ |\___ | | | | | ||| /_ | |
\____\____/\____\____/\____/ \_/ \_/ \|\____\ | |
_ _ _ ____ _____ ____ | |
/ \ /|/ \ /\/ \__/|/ _ \/ __// __\ | |
| |\ ||| | ||| |\/||| | //| \ | \/| | |
| | \||| \_/|| | ||| |_\| /_ | / | |
\_/ \|\____/\_/ \|\____/\____\_/\_\ | |
By Psycho_Coder @rawCoders | |
The game is simple a random number is chosen by this program everytime and you have to guess it right | |
If the number is less than what you guessed it will say "Too high guess" else "Too low" and if your | |
guess is correct then you are the winner.The number will be between 1 and 100 and you will get 5 chances | |
to guess it correctly | |
Enter Your Guess : | |
23 | |
You guessed the number too low | |
Enter Your Guess : | |
43 | |
You guessed the number too low | |
Enter Your Guess : | |
65 | |
You guessed the number too low | |
Enter Your Guess : | |
89 | |
You guessed the number too High | |
Enter Your Guess : | |
80 | |
You guessed the number too low | |
Aww! You Ran out of your chances. |