Skip to content

Commit 3b71d79

Browse files
authored
Merge pull request #6 from iamBijoyKar/add-project
[Added]: Number Guessing Cli Game Added
2 parents 1e16075 + 5e0e66c commit 3b71d79

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

Number_Guessing_CLI_Game.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
from random import randint
2+
from rich.console import Console
3+
import time
4+
console=Console()
5+
total_point,upper_limit,lose,level,chance=0,5,False,1,5
6+
while True:
7+
console.print(f"Guess The Number Between 1 and {upper_limit} , You Have {chance} Chances",style='bold yellow italic')
8+
wrong_answer_count,level_point=0,0
9+
while(True):
10+
if(wrong_answer_count>=chance):
11+
lose=True
12+
break
13+
console.print('Guess Your Number :',style='bold magenta',end="")
14+
guess_number=input()
15+
rand_val=randint(1,upper_limit)
16+
with console.status ("[bold green]Generatin...") as status:
17+
for i in range(1,11):
18+
time.sleep(.1)
19+
console.print(f'Random Generated Value is {rand_val}',style='bold green ')
20+
time.sleep(.5)
21+
if(str(rand_val) == guess_number):
22+
level_point+=100
23+
total_point+=level_point
24+
console.print(f' ** You Won ** \n Level {level} Completed',style='blink blue')
25+
time.sleep(.5)
26+
console.print(f'Total Point is {total_point} and Level Point is {level_point}',style='yellow bold')
27+
time.sleep(.5)
28+
level+=1
29+
console.print(f' Advance to Level {level}',style='green italic')
30+
time.sleep(.5)
31+
break
32+
else:
33+
wrong_answer_count+=1
34+
level_point-=10
35+
if(lose):
36+
time.sleep(.5)
37+
console.print(f' -- You Lose -- \n Total Point is {total_point} and Level Point is {level_point}',style='red on black bold')
38+
break
39+
upper_limit+=5
40+
chance+=1

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
- Camera -- `pip install opencv-python`
3333
- BMI Calculator
3434
- QR Code generator -- `pip install qrcode`
35+
- Number Guessing Cli Game -- `pip install rich`
3536

3637
### *TOOLS and LANGUAGES*
3738

0 commit comments

Comments
 (0)