NUMBER GUESSING GAME Program in Python
Program:
# Program developed by ARUN
# Copyrights owned by DATA DEMONS
from time import sleep as slp
from random import randint as rdnt
name = input("Please enter you name")
name = name.title()
org = "DATA DEMONS"
game_name = 'NUMBER GUESSING GAME'
begin = "Let's begin the game"
won = "You won the game"
out = "You lost the game"
GGuess = 'Your guess is greater than the number.'
LGuess = "Your guess is lesser than the number."
LevelList = ["Noob", "Pro", "Legend", "Ultra"]
game_over = "GAME OVER"
print("Hi!, ", end = '')
for i in name:
print(i, end = '')
slp(0.2)
print('. This is a ', end = '')
for j in game_name:
print(j, end = '')
slp(0.2)
print(', developed by ', end = '')
for k in org:
print(k, end = '')
slp(0.2)
print()
print("""RULES :-
1) The number to be guessed will be in range [1, 20].
2) You guessed numbers range must ne in the Range[1,20].
3) There are 4 game hardness level, you should choose one of it.
'Noob' - You will get 7 chances.
'Pro' - You will get 5 chances.
'Legend' - You will get 3 chances.
'Ultra' - You will get 1 chance.
4) Hints will be provided after each guess.
5) No empty enters.""")
Level = input("Enter you hardness level")
Level = Level.capitalize()
cinp = rdnt(1, 20)
pinp = ''
if Level in LevelList:
if Level == LevelList[3]:
pinp = int(input("Enter your guess:"))
if pinp == cinp:
print(cinp, "is the number to be guessed and you found it correct.")
for m in won:
print(m, end = '')
slp(0.2)
print()
else:
print(cinp, "is the number to be guessed and you found it wrong.")
for l in out:
print(l, end = '')
slp(0.2)
print()
elif Level == LevelList[2]:
Life = 3
while Life > 0 and pinp != cinp:
pinp = int(input("Enter your guess:"))
if pinp > cinp:
print("Your guess is greater than the number.")
Life -= 1
elif pinp < cinp:
print("Your guess is lesser than the number.")
Life -= 1
else:
if Life == 0:
print(cinp, "is the number to be guessed and you found it wrong.")
for l in out:
print(l, end = '')
slp(0.2)
print()
elif cinp == pinp:
print(cinp, "is the number to be guessed and you found it correct.")
for m in won:
print(m, end = '')
slp(0.2)
print()
elif Level == LevelList[1]:
Life = 5
while Life > 0 and pinp != cinp:
pinp = int(input("Enter your guess:"))
if pinp > cinp:
print("Your guess is greater than the number.")
Life -= 1
elif pinp < cinp:
print("Your guess is lesser than the number.")
Life -= 1
else:
if Life == 0:
print(cinp, "is the number to be guessed and you found it wrong.")
for l in out:
print(l, end = '')
slp(0.2)
print()
elif cinp == pinp:
print(cinp, "is the number to be guessed and you found it correct.")
for m in won:
print(m, end = '')
slp(0.2)
print()
elif Level == LevelList[2]:
Life = 7
while Life > 0 and pinp != cinp:
pinp = int(input("Enter your guess:"))
if pinp > cinp:
print("Your guess is greater than the number.")
Life -= 1
elif pinp < cinp:
print("Your guess is lesser than the number.")
Life -= 1
else:
if Life == 0:
print(cinp, "is the number to be guessed and you found it wrong.")
for l in out:
print(l, end = '')
slp(0.2)
print()
elif cinp == pinp:
print(cinp, "is the number to be guessed and you found it correct.")
for m in won:
print(m, end = '')
slp(0.2)
print()
for o in game_over:
print(o, end = '')
slp(0.2)
print()
Programmer details : Arun Meyyappan PL
Software used: Visual studio CODE
Version : 1.74
Documents and files download link
Python File(.py)
Text File(.txt)
0 Comments