Question: Complete the following functions and use them to complete the program so that is allows to people at the same keyboard to play a game
Complete the following functions and use them to complete the program so that is allows to people at the same keyboard to play a game of RackO
def getrackdeck racksize:
Deal the top racksize cards first racksize elements of the list of the deck into a new rack. We expect racksize to be between and The first card goes in the first slot, the second card goes in the second slot, and so forth. We assume lendeck racksize. Return the list of ints representing the rack.. deck is a list of ints and racksize is an int between and inclusive.
def taketurndeck discard, playerrack:
Take the player's turn. Give them the choice of drawing or taking the top card of the discard pile. If they draw they can replace a card or discard the draw. If they take the top card of the discard pile they must replace a card in their rack.
The parameter deck is a list of int represented the deck, discard is a list of ints representing the discard pile, and playerrack is a list of ints representing a player's rack
def placecardplayerrack, newcard, discard:
Ask the player which card to replace in their rack. Replace it with the given new card. Place the card removed from the player's rack at the top of the discard pile. Error checks until player enters a card that is currently in their rack.
The parameter playerrack is a list of ints representing the player's rack of cards, newcard is an it and discard is a list of ints representing the discard pile
def issortedrack:
Return True if this rack is sorted in ascending order, False otherwise. Do not create any new lists in this function. This means you are not to call the built in sorted function which creates a new list when called. The parameter rack is a list of ints
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
