Question: Write a Python program that allows the user to play Go Fish with the computer. A basic Go Fish game has the following rules: Each

Write a Python program that allows the user to play Go Fish with the computer. A basic Go Fish game has the following rules:
Each player is dealt a hand of 7 cards.
If either player has a pair, they pull the pair from their hands and place them on the table.
One player goes first. The player picks a card in their hand that they are trying to match, and they say, Do you have a Jack?
o If the other player has a Jack, the asking player gets that card and places both Jacks on the table
o If the other player does not have a Jack, they say Go Fish!
The asking player draws a card from the deck and puts it in their hand.
If the drawn card matches a card in the players hand, they place the pair on the table.
The game is over whenever one player runs out of cards or all the cards have been dealt.
The player with the most pairs at the end of the game wins, regardless of who ran out of cards first. Possible program functions.
1. Write a function that will create a deck of cards. Represent you deck of cards using a Python dictionary where the keys are the values 1-52 and the associated values are 2,3,4,5,6,7,8,9,10, Jack, Queen, King, Ace. We do not need to worry about the suits.
2. Once you have the card deck created, you will want to shuffle it. Below is an example of a function that will shuffle a deck of cards using the random modu
3.Write a function that will deal a card. Its parameter is a deck of cards. The function will remove and return the card from the top of the deck.
4. Write a function, find pairs, that receives a list representing a Go Fish hand, removes the pairs from the hand and returns a list of pairs.
5. Write a function, take turn, that represents a players turn. This function should receive as arguments the players hand and board, the opponents hand and the deck to cards. The player chooses a card from their hands and asks the opponent if they have that card. If they do, the card is removed from the opponents hand and the players hand and both are added to the players board. Otherwise, a card is dealt from the deck and added to the players hand. Play game of Go Fish (Note: we will refer to place pairs on the table as add pairs to either the player board or computer board).
1. Create deck of cards
2. Shuffle the cards
3. Play Game
a. Deal a card to the player and a card to the computer 7 times
b. Find player pairs and add pairs to the player board
c. Find computer pairs and add pairs to computer board
d. Print the Players hand and board
e. Print the Computers hand and board
f. While the player and computer still has cards in their hand and there are still cards in the deck
i. Player takes a turn
ii. Computer takes a turn
iii. Print the Players hand and board
iv. Print the Computers hand and board
g. If the player has more

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!