Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

( 1 ) Define a function which will draw a poker card from the top of deck. In the function, convert card names to points:

(1) Define a function which will draw a poker card from the top of deck.
In the function, convert card names to points:
Ace: 11 points
Jack: 10 points
Queen: 10 points
King: 10 points
0thers: points = card face number
Return will be the card's points and card name.
(2) Write a driver program to test the function above
use a loop to draw as many cards as user wants
use a list to hold the returned points
use a list to hold the returned names
finally, print out total points and all cards names
drawing card without replacing.
Coding here:
# A deck list of shuffled poker cards is given
import random
# deck: given list of 52 poker cards.
values =[ "ace", "2","3","4","5","6","7","8","9","10", "jack", "queen", "king" ]
suits =[ "clubs", "diamonds", "hearts", "spades" ]
deck =[v+"of_"+s for s in suits for v in values ]
random.shuffle(deck)
deck
# print(deck)
#==============
# (1) your function
should me look like below :
Sample Run
card name: 4_of_diamonds, point: 4
play again(anykey) or exit (y):
card name: 3_of_diamonds, point: 3
play again(anykey) or exit (y):
card name: 5_of_clubs, point: 5
play again(anykey) or exit (y):
card name: 6_of_spades, point: 6
play again(anykey) or exit (y):y
Total points: 18
They are: ['4_of_diamonds', '3_of_diamonds', '5_of_clubs', '6_of_spades']
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems Uropean Conference Adbis 2020 Lyon France August 25 27 2020 Proceedings Lncs 12245

Authors: Jerome Darmont ,Boris Novikov ,Robert Wrembel

1st Edition

3030548317, 978-3030548315

More Books

Students also viewed these Databases questions