import pandas as pd
import random as random
def card():
pack ={} #empty dictionary
x=[] # empty list for card
y=[] # empty list for shape
z=[] # empty list for color
for i in range(3): # for 3 card
cd = random.choice(['A','2','3','4','5','6','7','8','9','10','J','Q','K'])
x.append(cd)
s = random.choice(['Diamond', 'Spade', 'Club','Heart'])
y.append(s)
if(s=='Diamond' or s=='Heart'):
c='Red'
else:
c='Black'
z.append(c)
pack.update({'Card':x,'Shape':y,'Color':z})
return pack
data=card()
data
{'Card': ['4', 'K', 'Q'], 'Shape': ['Diamond', 'Spade', 'Spade'], 'Color': ['Red', 'Black', 'Black']}
DF=pd.DataFrame(data)
DF
Card | Shape | Color | |
---|---|---|---|
0 | 4 | Diamond | Red |
1 | K | Spade | Black |
2 | Q | Spade | Black |
DF.Card[1]
'K'
DF.Shape[2]
'Spade'
DF.Color[0]
'Red'
if(DF.Card[0]==DF.Card[1] and DF.Card[1]==DF.Card[2]): #3 same card
if(DF.Card[0]=='A'):
print('Congratulation! You win Rs 800')
elif(DF.Card[0]=='K'):
print('Congratulation! You win Rs 700')
else:
print('You win Rs 600')
elif(DF.Shape[0]==DF.Shape[1] and DF.Shape[1]==DF.Shape[2]): #3 same shape
print('You win Rs 500')
elif(DF.Card[0]==DF.Card[1] or DF.Card[1]==DF.Card[2] or DF.Card[0]==DF.Card[2]):#2 same card
if(DF.Shape[0]==DF.Shape[1] and DF.Shape[1]==DF.Shape[2]): #3 same shape
print('You win Rs 300')
elif(DF.Shape[0]==DF.Shape[1] or DF.Shape[1]==DF.Shape[2] or DF.Shape[0]==DF.Shape[2]):# 2 same shape
print('You win Rs 200')
else:
print('you win Rs 100')
elif(DF.Shape[0]==DF.Shape[1] or DF.Shape[1]==DF.Shape[2] or DF.Shape[0]==DF.Shape[2]):# 2 same shape
if(DF.Color[0]==DF.Color[1] and DF.Color[1]==DF.Color[2]): # 3 same color
print('You win Rs 80')
else:
print('you win Rs 50')
elif(DF.Color[0]==DF.Color[1] and DF.Color[1]==DF.Color[2]): # 3 same color
print('You win Rs 20')
else:
print('you loss Rs 100')
you win Rs 50