Question: Write a program in Python to implement the game of 2 1 . Main content The Game For this assignment you will be making a

Write a program in Python to implement the game of 21.
Main content
The Game
For this assignment you will be making a simple version of the game of 21.
Rules:
For each round, the player starts with 0
You should keep track of the wins and losses for the player
You should repeatedly ask the player if he would like another card until he answers no
Each time the player asks for another card, generate a random number between 2 and 11. Display the players updated score.
If the players card puts him over 21, he busts. Print out that he busted and count this as a loss
Once the player has stopped, the dealer (the computer) gets to go
The computer starts at 0 and takes cards using the following rule: if the total is less than 16, it takes another card. If it is 16 or higher, it stays.
If the computer gets over 21, it busts and the player wins
If the player has a higher score than the computer, the player wins, and one is added to the players wins
If the player has a lower score, the player loses, and one is added to the players losses
If both the player and the computer have the same score, the game is a tie and no win or loss is recorded
You should print out the score for both the player and computer and who won the round
After each round, you should ask if the player wants to play again. If so, play another round. If not, output the final number of wins and losses and end the program.

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!