Skip to content

Commit 6f346a6

Browse files
committed
added blackjack
1 parent 7bcabaf commit 6f346a6

File tree

2 files changed

+123
-6
lines changed

2 files changed

+123
-6
lines changed

blackJack/main.py

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
2+
# BLACK JACK - CASINO A GAME OF FORTUNE!!!
3+
import time
4+
5+
# BLACK JACK - CASINO
6+
# PYTHON CODE BASE
7+
import random
8+
9+
deck = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11] * 4
10+
11+
random.shuffle(deck)
12+
13+
14+
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+
while len(d_cards) != 2:
33+
random.shuffle(deck)
34+
d_cards.append(deck.pop())
35+
if len(d_cards) == 2:
36+
print('The cards dealer has are X ', d_cards[1])
37+
38+
# Displaying the Player's cards
39+
while len(p_cards) != 2:
40+
random.shuffle(deck)
41+
p_cards.append(deck.pop())
42+
if len(p_cards) == 2:
43+
print("The total of player is ", sum(p_cards))
44+
print("The cards Player has are ", p_cards)
45+
46+
if sum(p_cards) > 21:
47+
print("You are BUSTED !\n **************Dealer Wins !!******************\n")
48+
exit()
49+
50+
if sum(d_cards) > 21:
51+
print("Dealer is BUSTED !\n ************** You are the Winner !!******************\n")
52+
exit()
53+
54+
if sum(d_cards) == 21:
55+
print("***********************Dealer is the Winner !!******************")
56+
exit()
57+
58+
if sum(d_cards) == 21 and sum(p_cards) == 21:
59+
print("*****************The match is tie !!*************************")
60+
exit()
61+
62+
# function to show the dealer's choice
63+
def dealer_choice():
64+
if sum(d_cards) < 17:
65+
while sum(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+
if sum(p_cards) == sum(d_cards):
72+
print("***************The match is tie !!****************")
73+
exit()
74+
75+
if sum(d_cards) == 21:
76+
if sum(p_cards) < 21:
77+
print("***********************Dealer is the Winner !!******************")
78+
elif sum(p_cards) == 21:
79+
print("********************There is tie !!**************************")
80+
else:
81+
print("***********************Dealer is the Winner !!******************")
82+
83+
elif sum(d_cards) < 21:
84+
if sum(p_cards) < 21 and sum(p_cards) < sum(d_cards):
85+
print("***********************Dealer is the Winner !!******************")
86+
if sum(p_cards) == 21:
87+
print("**********************Player is winner !!**********************")
88+
if sum(p_cards) < 21 and sum(p_cards) > sum(d_cards):
89+
print("**********************Player is winner !!**********************")
90+
91+
else:
92+
if sum(p_cards) < 21:
93+
print("**********************Player is winner !!**********************")
94+
elif sum(p_cards) == 21:
95+
print("**********************Player is winner !!**********************")
96+
else:
97+
print("***********************Dealer is the Winner !!******************")
98+
99+
100+
while sum(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+
if k == 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+
if sum(p_cards) > 21:
110+
print('*************You are BUSTED !*************\n Dealer Wins !!')
111+
if sum(p_cards) == 21:
112+
print('*******************You are the Winner !!*****************************')
113+
114+
115+
else:
116+
dealer_choice()
117+
break

passwordManager/info.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---------------------------------
2-
UserName: ani
3-
Password: jakdmsPc
4-
Website: a na
2+
UserName: Aniket
3+
Password: 123456
4+
55
---------------------------------
66

77
---------------------------------
8-
UserName: aniket
9-
Password: oGfvqm*Pq1
10-
Website: aniketindian@
8+
UserName: Biswa bhaiya
9+
Password: Hi bhaiya!
10+
1111
---------------------------------
1212

0 commit comments

Comments
 (0)