Question: in Python: This is a card game called High Low. The computer and player take turns presenting their cards. The one with the highest value

in Python:
This is a card game called High Low. The computer and player take turns presenting their cards. The one with the highest value card wins. After each hand, the cards used in this round will be available for the next round, as if they were put back into the deck (i.e. no change to the card list).
The card list is saved in an external file. You will need to read the cards in as list. Cards are formatted in the text file as Face Value Suit: AS is Ace of Spaces, 4H is 4 of Hearts, the 10C is the 10 of Clubs.
Royal face cards (K, Q, J) are worth 10 and the Ace is worth 1 for comparison value between cards.
Process:
The card deck is stored in an external file: cards.txt.
The computer will pull a random card from the list holding the deck.
The user will pull a random card from the list of cards.
Printout the computer's card and the player's card.
The program should them compare the value of the computer and player cards. The one with the highest value wins.
Wins, ties, and losses should be tracked for both the player and the computer.
The user will be asked how many hands of cards they want to play (rounds).
The game should run for that many rounds and record a running count of the wins, ties, and losses for both the user and the computer.
Game should use the following functions:
main(),
getDeck(),
compareHands(),
storeScores()
Others may be added/used as needed.
The getDeck() should read the cards from the external text file cards.txt. Then process the cards into a list for use in the game. Pass the card deck back to the rest of the program to be used.
The compareHands() function should allow the user to pick a card Ace King and set the computer's card (hand) to a random card from the deck. Hint: indexes are numbers and random module can give a number.
Comparing cards means you need to determine the value of the card. If the card is 2 characters in length vs 3, will make a difference how you'll process the value?
AC vs 9C vs 10C?
Compare the value of the two hands (player vs computer).
For the one with the higher valued card, increase the win count by one, f
or a tie,
increase both computer and player's tie count by one,
and increase loss count by one for the one who has the lower card.
Let the player know who won/tied/lost.
The main() should control the sequence of the game and call and receive information from the functions as needed. The loop for the game should be controlled in the main() function and call other functions as needed and pass values as needed.
Remember to call the main() at the end of the program, outside the other functions, to start the program. Do not define functions in other structures, they are stand alone elements.
At the end of the game, the scores for wins, ties, and losses for both the player and the computer should be saved to an external file named scores.txt.
Be sure to open and close files appropriately.

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!