Question
Can someone show me how to do this in python? I'm so new to python. TEXT The functions are to support the card game of
Can someone show me how to do this in python? I'm so new to python.
TEXT The functions are to support the card game of Blackjack or 21
The object of the game is to have a hand that adds up to 21 points, or as close to 21 as possible without going over
The 2 through 10 cards are worth the same number of points
The face cards are each worth 10 points
An ace can be worth either 1 or 11 points, whichever is better
Ex: a hand of a king, a 3 and an ace is worth 14 points (scoring the ace as 11 points would go over the limit of 21)
Suits (spades, hearts, diamonds, clubs) do not affect the score
Specific to this assignment,
Cards are represented as a tuple of the value (an int) and a suit (a string) you cannot modify an existing tuples values, so this prevents us from accidentally adding more elements to a card
A hand is represented as a list of Cards (you can add on to lists using the append method). We want to be able to modify a hand so when dealing cards, we can add a card to a hand.
The deck is also a list
Overall, note that you should not use Python's print to do any of these functions. You may find it useful to print out debugging information, but these are all functions that return values. (In any language, if you are asked to write a function that returns the sum of its arguments, you cannot just print the sum, which does not return anything that other parts of the program could use. Using cout or System.out.print would be wrong.)
The functions:
deal(deck, hands)
deck is a list of cards
hands is a tuple of empty hands
distribute the cards in alternating order to all of the hands
Returns the updated hands parameter
score(hand)Returns the number of points of the hand
Count Aces as 1 only if the point total would otherwise be over 21 ex: 2 aces counts as 12
Return 0 for an empty hand
This assignment is intended to give you a first taste of Python. You are required to implement the following functions, though of course you may write other functions to help you complete the task. The functions are to support the card game of Blackjack or 21 o The object of the game is to have a hand that adds up to 21 points, or as close to 21 as possible without going over The 2 through 10 cards are worth the same number of points The face cards are cach worth 10 points o An ace can be worth cither1 or 1 points, whichever is better Ex: a hand of a king, a 3 and an ace is worth 14 points (scoring the ace as 11 points would go over the limit of 21) suits (spades, hearts, diamonds, clubs) do not affect the score .Specific to this assignment, o Cards are represented as a tuple of the value (an int) and a suit (a string)-you cannot modify an existing tuplc's values, so this prevents us from accidentally adding more clements to a card o A hand is represented as a list of Cards you can add on to lists using the a end method). We want to be able o modify a hand so when dealing cards, we can add a card to a hand. The dcck is also a list Overall, note that you should not use Python's print to do any of these functions. You may find it useful to print out debugging information, but these are all functions that return values. (In any language, if you are asked to write a function that rcturns the sum of its arguments, you cannot just print the sum, which docs not return anything that other parts of the program could use. Using cout or System.out.print would be wrong.) The functions: deal (deck, hands) o deck is a list of cards o hands is a tuple of empty hands distribute the cards in alternating order to all of the hands o Returns the updated hands parameter score (hand) Returns the number of points of the hand 5 Count Accs as 1 only if the point total would othcrwise be ovcr 21 -cx: 2 aces counts as 12 o Retum 0 for an empty handStep 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