Answered step by step
Verified Expert Solution
Question
1 Approved Answer
this is a python code Question 4 Write a program to play a version of a three-card game with the computer. Call the file containing
this is a python code
Question 4 Write a program to play a version of a three-card game with the computer. Call the file containing your program, playcards.py. Assume that the face value and the suit of the each card is represented as follows: Face Value: The numbers 2 to 10 represent the corresponding face value cards (i.e., cards numbered from 2 to 10) 11 represents a Jack 12 represents a Queen 13 represents a King 14 represents an Ace Suit: 1 represents Hearts 2 represents Clubs 3 represents Diamonds 4 represents Spades The game is played against the computer. Your program should ask for the player's first name and then generate 7 random numbers: 3 integers between 2 and 14, inclusive; one for the face value of each of the three cards 3 integers between 1 and 4, inclusive; one for the suit of each of the three cards 1 integer between 7 and 45, inclusive, representing the score for the computer Compute the sum of the face value of the three cards that have been randomly drawn for the player, plus the points allocated based on the suit of the cards using the following rules: if all three cards have the same suit then add three points to the sum of the faces value of the three cards if two of the cards have the same suit and the third card has a different suit then add 2 points to the sum of the faces value of the three cards if all three cards have different suits then add 1 point to the sum of the faces value of the three cards Determine and declare the winner (computer, player's name or tied), displaying the computed points for the player and the randomly selected points for the computer. The output from the program could be as follows: Please enter your first name: Sandy Sandy total is 35 Computer total is 20 Sandy congratulations, you are the winner. If you run the program again then the output from the code could be as follows: Please enter your first name: Mandy Mandy total is 37 Computer total is 44 Sorry Mandy you have lost to your opponentStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started