-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroulette.py
More file actions
60 lines (48 loc) · 1.63 KB
/
roulette.py
File metadata and controls
60 lines (48 loc) · 1.63 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
# -*-coding:utf-8 -*
#
# Roulette game
##
from random import randrange
from math import ceil
playing = True
money = 1000
while playing:
choosed_number = -1
while choosed_number < 0 or choosed_number > 49:
try:
choosed_number = int(raw_input("Please, enter a number between 0 and 49 : "))
except ValueError:
print("Wrong number")
if choosed_number < 0 or choosed_number > 49:
print("> Error: %i is not a number between 0 and 49 !!! " % choosed_number)
bid_amount = 0
while bid_amount <= 0 or bid_amount > money:
try:
bid_amount = int(raw_input("Now, choose the amount of your bet : "))
except ValueError:
print("Wrong amount")
if bid_amount <= 0:
print("The amount should greater than « 0 »")
if bid_amount > money:
print("You can't bet more than %i" % money)
random_number = randrange(0,49)
print("The roulette rotates... and the number is... « %i » !" % random_number)
if random_number == choosed_number:
amount_win = bid_amount*3
money += amount_win
print("Congrats, you win %i$ !" % amount_win)
elif random_number%2 == choosed_number%2:
amount_win = ceil(bid_amount*0.5)
money += amount_win
print("Good, the number has same color, you win %i$ !" % amount_win)
else:
money -= bid_amount
print("Sorry, you loses %i$" % bid_amount)
if money <= 0:
playing = False
print("Sorry, you have no enough money, go see the cashier plzkthx")
else:
play_again = raw_input("Want to make another bet ? (y)es / (n)o : ")
if play_again == "n":
playing = False
print("Goodbye, you leaves the table with %i$ !" % money)