Question: Please write the code in python Part One: calculating offsets define the following variables (the first one is done for you) diamond_offset - 0 #
Please write the code in python


Part One: calculating offsets define the following variables (the first one is done for you) diamond_offset - 0 # holds the index of the first club_offset = # holds the index of the first heart_offset - # holds the index of the first spade_offset - # holds the index of the first Hint: do NOT use hard coded numbers other than the zero for diamonds. Come up with a mathematical expression to define the value (rather than saying heart_offset = 34) using the cards_per_suit variable. For example (this is not mathematically correct :) club_offset - diamond_offset * (cards_per_suit + 1) How would you test these offsets before moving on? Part Two: dealing from the deck define and test the following functions: first_card_in_deck(deck) which returns the first card in the deck .last_card_in_deck(deck) returns the last card in the deck first_heart (deck) returns the first in the deck NOTES you can assume the following: the deck parameter will always be a set of cards in the A-K and order Part Three: get_card Create the function get_card(deck, suit, rank) which returns the relevant card from the deck: suit will be one of O+V4 rank will be a number 1 through 13 corresponding to (A, 2, 3 ..J,Q,K) In your code you need to calculate the appropriate index so you can do return deck[ calculated_index_value] For example to get the Q you could use get_card like this: card - get_card(cards, '"', 12) print(card) # it should be the Queen of Hearts! You MUST use the following restrictions: do not use any hard coded offsets (e.g. 23, 12) you can use the literals 0,1,2,3,4 only don't use 13, use cards_per_suit) .no hard coded cards (e.g return 'AO) you can reference the variables defined in part one Part Four: using get_card write the following function: first_heart_v2(deck) returns the first in the deck .it MUST use get_card with the proper parameters
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
