You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
print('********************************************************** \n Welcome to the game Casino - BLACK JACK ! \n**********************************************************')
15
+
time.sleep(2)
16
+
print('So Finally You Are Here To Accept Your Fate')
17
+
time.sleep(2)
18
+
print('I Mean Your Fortune')
19
+
time.sleep(2)
20
+
print('Lets Check How Lucky You Are Wish You All The Best')
21
+
time.sleep(2)
22
+
print('Loading---')
23
+
time.sleep(2)
24
+
25
+
print('Still Loading---')
26
+
time.sleep(2)
27
+
print('So You Are Still Here Not Gone I Gave You Chance But No Problem May Be You Trust Your Fortune A Lot \n Lets Begin Then')
28
+
time.sleep(2)
29
+
d_cards= [] # Initialising dealer's cards
30
+
p_cards= [] # Initialising player's cards
31
+
time.sleep(2)
32
+
whilelen(d_cards) !=2:
33
+
random.shuffle(deck)
34
+
d_cards.append(deck.pop())
35
+
iflen(d_cards) ==2:
36
+
print('The cards dealer has are X ', d_cards[1])
37
+
38
+
# Displaying the Player's cards
39
+
whilelen(p_cards) !=2:
40
+
random.shuffle(deck)
41
+
p_cards.append(deck.pop())
42
+
iflen(p_cards) ==2:
43
+
print("The total of player is ", sum(p_cards))
44
+
print("The cards Player has are ", p_cards)
45
+
46
+
ifsum(p_cards) >21:
47
+
print("You are BUSTED !\n **************Dealer Wins !!******************\n")
48
+
exit()
49
+
50
+
ifsum(d_cards) >21:
51
+
print("Dealer is BUSTED !\n ************** You are the Winner !!******************\n")
52
+
exit()
53
+
54
+
ifsum(d_cards) ==21:
55
+
print("***********************Dealer is the Winner !!******************")
56
+
exit()
57
+
58
+
ifsum(d_cards) ==21andsum(p_cards) ==21:
59
+
print("*****************The match is tie !!*************************")
60
+
exit()
61
+
62
+
# function to show the dealer's choice
63
+
defdealer_choice():
64
+
ifsum(d_cards) <17:
65
+
whilesum(d_cards) <17:
66
+
random.shuffle(deck)
67
+
d_cards.append(deck.pop())
68
+
69
+
print("Dealer has total "+str(sum(d_cards)) +"with the cards ", d_cards)
70
+
71
+
ifsum(p_cards) ==sum(d_cards):
72
+
print("***************The match is tie !!****************")
73
+
exit()
74
+
75
+
ifsum(d_cards) ==21:
76
+
ifsum(p_cards) <21:
77
+
print("***********************Dealer is the Winner !!******************")
78
+
elifsum(p_cards) ==21:
79
+
print("********************There is tie !!**************************")
80
+
else:
81
+
print("***********************Dealer is the Winner !!******************")
82
+
83
+
elifsum(d_cards) <21:
84
+
ifsum(p_cards) <21andsum(p_cards) <sum(d_cards):
85
+
print("***********************Dealer is the Winner !!******************")
86
+
ifsum(p_cards) ==21:
87
+
print("**********************Player is winner !!**********************")
88
+
ifsum(p_cards) <21andsum(p_cards) >sum(d_cards):
89
+
print("**********************Player is winner !!**********************")
90
+
91
+
else:
92
+
ifsum(p_cards) <21:
93
+
print("**********************Player is winner !!**********************")
94
+
elifsum(p_cards) ==21:
95
+
print("**********************Player is winner !!**********************")
96
+
else:
97
+
print("***********************Dealer is the Winner !!******************")
98
+
99
+
100
+
whilesum(p_cards) <21:
101
+
102
+
#to continue the game again and again !!
103
+
k=input('Want to hit or stay?\n Press 1 for hit and 0 for stay ')
104
+
ifk==1:
105
+
random.shuffle(deck)
106
+
p_cards.append(deck.pop())
107
+
print('You have a total of '+str(sum(p_cards))
108
+
+' with the cards ', p_cards)
109
+
ifsum(p_cards) >21:
110
+
print('*************You are BUSTED !*************\n Dealer Wins !!')
111
+
ifsum(p_cards) ==21:
112
+
print('*******************You are the Winner !!*****************************')
0 commit comments