[Solved]Please Todo Function Computehandscore Hands Program Import Random Def Main Playcard1 Dealc Q37023259
Please do the#TODO function of computeHandScore hands for thisprogram:
import random
def main():
playCard1=dealCard([]) #no cards drawn yet
houseCard1=dealCard([playCard1])
playCard2=dealCard([playCard1,houseCard1])
houseCard2=dealCard([playCard1,houseCard1,playCard2])
print(“Player’s Hand: “+playCard1+”, “+playCard2)
playScore = computeHandScore(playCard1, playCard2)
print(“The player has ” + playScore + ” points”)
print(“House’s Hand: “+houseCard1+”, “+houseCard2)
houseScore = computeHandScore(houseCard1, houseCard2)
print(“The player has ” + houseScore + ” points”)
#TODO: Add in the computeHandScore function, so that itwill compute the value given the two cards passed.
def dealCard(dealtCardList):
“””
Randomly selects a new card out of 52 possibilties, if the card isalready chosen (c1-c4)
then another random card is chosen (repeating until a card drawnhasn’t been seen)
:param dealtCardList alist containing strings representing the card face(A,K,Q,J,10,9…) followed by a suit (H,D,S,C) that were alreadydealt
:return the String representation of the card (value followed bysuit), examples: 2H (2 of hearts), KS (King of Spades),…etc
“””
cardN = random.randrange(0,52)
cardFace = convertNumToCard(cardN) # Returns 2H or AD forexample
while cardFace in dealtCardList: # Card already dealt…need a newone
cardN = random.randrange(0,52)
cardFace = convertNumToCard(cardN) # Returns 2H or AD forexample
return(cardFace)
def convertNumToCard(card):
“””
Converts a numberic value (0-51) into a String representation:FaceValue followed by the Suit, examples: 2H (2 of hearts), KS(King of Spades),…etc
:param card a numericrepresentation of the card 0-51 (52 cards in a deck)
:return the String representation of the card (value followed bysuit), examples: 2H (2 of hearts), KS (King of Spades),…etc
“””
suitV = card//13
cardV = card%13+2
cardFace=””
if cardV<11: cardFace+=str(cardV) # 2-10
elif cardV==11: cardFace+=”J”
elif cardV==12: cardFace+=”Q”
elif cardV==13: cardFace+=”K”
elif cardV==14: cardFace+=”A”
if suitV==0: cardFace+=”H” # hearts
if suitV==1: cardFace+=”C” # clubs
if suitV==2: cardFace+=”D” # diamonds
if suitV==3: cardFace+=”S” # spades
return(cardFace)
main()
Expert Answer
Answer to Please do the #TODO function of computeHandScore hands for this program: import random def main(): playCard1=dealCard([]… . . .
OR

