-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSlotMachine.py
More file actions
70 lines (59 loc) · 1.88 KB
/
SlotMachine.py
File metadata and controls
70 lines (59 loc) · 1.88 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#PYTHON SLOT MACHINE GAME -------
# 🥭, 🍎, 🍖, 🐟, 🥕
import random
def row():
result = [random.choice(["🥭", "🍎", "🍖", "🐟", "🥕"]) for _ in range(3)]
return result
def spin(result):
print("******************")
print(f" {' | '.join(result)}")
print("******************")
def pay(amount, result):
if result[0] == result[1] == result[2]:
if result[0] == "🥭":
return amount * 8
elif result[0] == "🍎":
return amount * 7
elif result[0] == "🍖":
return amount * 6
elif result[0] == "🐟":
return amount * 5
elif result[0] == "🥕":
return amount * 4
return 0
def main(balance):
print("-----MACHINE SLOT GAME--------")
print("Symbols:🥭, 🍎, 🍖, 🐟, 🥕")
print("your account balance is", balance)
while balance > 0:
amount = input("enter the amount to play or Q to exit: ").upper()
if amount == "Q":
print("you are Exit")
break
if not amount.isdigit():
print("Enter the valid amount to play!")
continue
amount = int(amount)
if amount <= 0:
print("Amount should be greater tha zero! ")
continue
if amount > balance:
print("Insufficient Balance! ")
continue
balance -= amount
# print(row())
result = row()
print("Spinning........")
spin(result)
pay_out = pay(amount, result)
if pay_out > 0:
print(f"--YOU WON🥳---${pay_out}")
balance += pay_out
else:
print("you lost this round😓")
print("your current balance is ", balance)
else:
print("Insufficient Balance ")
if __name__ == "__main__":
balance = int(input("Recharge the balance you want:"))
main(balance)