-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathNumber_Guessing_CLI_Game.py
More file actions
40 lines (40 loc) · 1.56 KB
/
Number_Guessing_CLI_Game.py
File metadata and controls
40 lines (40 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from random import randint
from rich.console import Console
import time
console=Console()
total_point,upper_limit,lose,level,chance=0,5,False,1,5
while True:
console.print(f"Guess The Number Between 1 and {upper_limit} , You Have {chance} Chances",style='bold yellow italic')
wrong_answer_count,level_point=0,0
while(True):
if(wrong_answer_count>=chance):
lose=True
break
console.print('Guess Your Number :',style='bold magenta',end="")
guess_number=input()
rand_val=randint(1,upper_limit)
with console.status ("[bold green]Generatin...") as status:
for i in range(1,11):
time.sleep(.1)
console.print(f'Random Generated Value is {rand_val}',style='bold green ')
time.sleep(.5)
if(str(rand_val) == guess_number):
level_point+=100
total_point+=level_point
console.print(f' ** You Won ** \n Level {level} Completed',style='blink blue')
time.sleep(.5)
console.print(f'Total Point is {total_point} and Level Point is {level_point}',style='yellow bold')
time.sleep(.5)
level+=1
console.print(f' Advance to Level {level}',style='green italic')
time.sleep(.5)
break
else:
wrong_answer_count+=1
level_point-=10
if(lose):
time.sleep(.5)
console.print(f' -- You Lose -- \n Total Point is {total_point} and Level Point is {level_point}',style='red on black bold')
break
upper_limit+=5
chance+=1