Question: Write a war card game in python that does the following: There will be 3 rounds. (perhaps use a for loop) At the beginning of

Write a war card game in python that does the following:

There will be 3 rounds. (perhaps use a for loop)

At the beginning of each round, deal 10 "cards" to the player and the computer. The cards will have integer values from 1 to 10 and you can have multiple cards of the same value.

For each turn

The computer shows the player's hand and the player choose a card from the player's hand. The computer will chose a random card in their pile.

The card with the larger number wins.

If there is a tie, those cards remain in limbo until someone wins a turn and then all cards go to the winner.

The cards are removed from the player and the computer's hand as they are selected.

The winner will have the most cards at the end of the game. Display the player and computer scores and determine the winner at the end of the game.

Your program must use lists - one for the computer's cards and 1 for the player's cards. The easiest way to populate the the lists would be hand.append(randint(1,10)).

Your program must implement at least 1 function. I suggest dealCards (numberOfCards) as the function where you pass the number of cards to deal and it returns a list containing the randomly generated cards.

Attach your .py file.

Here is my sample output:

[2, 3, 4, 3, 4, 7, 5, 1, 2, 6] Which card do you want to play? 7 [2, 3, 4, 3, 4, 5, 1, 2, 6] Which card do you want to play? 6 [2, 3, 4, 3, 4, 5, 1, 2] Which card do you want to play? 5 [2, 3, 4, 3, 4, 1, 2] Which card do you want to play? 4 [2, 3, 3, 4, 1, 2] Which card do you want to play? 3 [2, 3, 4, 1, 2] Which card do you want to play? 4 [2, 3, 1, 2] Which card do you want to play? 3 [2, 1, 2] Which card do you want to play? 2 [1, 2] Which card do you want to play? 1 [2] Which card do you want to play? 2 Round 1 Computer 14 and player 6 [7, 9, 7, 9, 2, 1, 9, 3, 8, 6] Which card do you want to play? 9 [7, 7, 9, 2, 1, 9, 3, 8, 6] Which card do you want to play? 9 [7, 7, 2, 1, 9, 3, 8, 6] Which card do you want to play? 9 [7, 7, 2, 1, 3, 8, 6] Which card do you want to play? 8 [7, 7, 2, 1, 3, 6] Which card do you want to play? 7 [7, 2, 1, 3, 6] Which card do you want to play? 7 [2, 1, 3, 6] Which card do you want to play? 6 [2, 1, 3] Which card do you want to play? 3 [2, 1] Which card do you want to play? 2 [1] Which card do you want to play? 1 Round 2 Computer 20 and player 18 [4, 6, 1, 3, 9, 7, 10, 6, 1, 4] Which card do you want to play? 10 [4, 6, 1, 3, 9, 7, 6, 1, 4] Which card do you want to play? 9 [4, 6, 1, 3, 7, 6, 1, 4] Which card do you want to play? 7 [4, 6, 1, 3, 6, 1, 4] Which card do you want to play? 6 [4, 1, 3, 6, 1, 4] Which card do you want to play? 6 [4, 1, 3, 1, 4] Which card do you want to play? 4 [1, 3, 1, 4] Which card do you want to play? 4 [1, 3, 1] Which card do you want to play? 3 [1, 1] Which card do you want to play? 1 [1] Which card do you want to play? 1 Round 3 Computer 34 and player 26 You Lost :( Computer 34 and player 26

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 Databases Questions!