-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrandom_1.py
More file actions
32 lines (26 loc) · 785 Bytes
/
random_1.py
File metadata and controls
32 lines (26 loc) · 785 Bytes
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
import random
print("""Welcome to the Coin Guessing Game!
Choose a method to toss the coin:
1.Using random.random()
2.Using random.randint()""")
choice=input(print("Enter your choice (1 or 2):"))
if choice== "1":
random_number = random.random()
if random_number >= 5:
computer_result = "KING"
else:
computer_result = "CROWN"
elif choice == "2":
random_numb2 = random.randint(0.1)
if random_numb2 == 0:
computer_result = "KING"
else:
computer_result = "CROWN"
else:
print("Sorry! choice 1 or 2.")
choice_1=input(print("choice KING or CROWN:")).lower()
if choice_1 == computer_result:
print("Congrulations!You Won.")
else:
print(f"""Sorry! you lose wrong choice.
the right choice is :{computer_result}.""")