Skip to content

Commit bc0abb9

Browse files
committed
Addedhead_tail_random_module.py to Python-Basic-to-Advance repo
1 parent 3e3e77c commit bc0abb9

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

head_tail_random_module.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import random
2+
print("Welcome to the head-tail Game..!!")
3+
4+
round=5
5+
user_head=0
6+
computer_head=0
7+
8+
for toss in range(1,round+1):
9+
print(f"\n Toss:{toss}")
10+
11+
user_result=random.choice(["head","tail"])
12+
print("User:",user_result)
13+
14+
computer_result=random.choice(["head","tail"])
15+
print("Computer:",computer_result)
16+
17+
if user_result=="head":
18+
user_head+=1
19+
if computer_result=="head":
20+
computer_head+=1
21+
22+
# ✅ Final winner check loop नंतर
23+
if user_head>computer_head:
24+
print("User WINS the Game!")
25+
elif computer_head>user_head:
26+
print("Computer WINS the Game!")
27+
else:
28+
print("Match DRAW!")

0 commit comments

Comments
 (0)