Answered step by step
Verified Expert Solution
Question
1 Approved Answer
from cap import Player, generate _ random _ hand, create _ deck def play ( player: Player ) - > None: print ( Welcome
from cap import Player, generaterandomhand, createdeck
def playplayer: Player None:
printWelcome to Sleuth!"
questionsasked
incorrectguesses
guessedcards set
while lenguessedcards:
printWould you like to:
print Ask a question."
print Guess a card."
choice inputWhich option would you like?
if choice :
questionsasked
printWhich question would you like to ask?"
print How many cards with a certain colour?"
print How many cards with a certain shape?"
print How many cards with a certain number?"
print How many cards with a certain colour and number?"
print How many cards with a certain shape and number?"
print How many cards with a certain colour and shape?"
questionchoice inputWhich option would you like?
if questionchoice in :
printThe colour options are:"
print RED"
print BLUE"
print GREEN"
print YELLOW"
colour inputWhich colour do you want? upper
if colour :
colour "RED"
elif colour :
colour "BLUE"
elif colour :
colour "GREEN"
elif colour :
colour "YELLOW"
if questionchoice in :
printThe shape options are:"
print HEXAGON"
print CIRCLE"
print DIAMOND"
print RHOMBUS"
shape inputWhich shape do you want? upper
if shape :
shape "HEXAGON"
elif shape :
shape "CIRCLE"
elif shape :
shape "DIAMOND"
elif shape :
shape "RHOMBUS"
if questionchoice in :
number intinputEnter a number from inclusive:
if questionchoice :
count player.countcardscolourcolour
printfThe player has count cards with colour colour
elif questionchoice :
count player.countcardsshapeshape
printfThe player has count cards with shape shape
elif questionchoice :
count player.countcardsnumbernumber
printfThe player has count cards with number number
elif questionchoice :
count player.countcardscolourcolour, numbernumber
printfThe player has count cards with colour colour and number number
elif questionchoice :
count player.countcardsshapeshape, numbernumber
printfThe player has count cards with shape shape and number number
elif questionchoice :
count player.countcardscolourcolour, shapeshape
printfThe player has count cards with colour colour and shape shape
else:
printThat is not an option, try again."
elif choice :
printThe colour options are:"
print RED"
print BLUE"
print GREEN"
print YELLOW"
colour inputWhich colour do you want? upper
if colour :
colour "RED"
elif colour :
colour "BLUE"
elif colour :
colour "GREEN"
elif colour :
colour "YELLOW"
printThe shape options are:"
print HEXAGON"
print CIRCLE"
print DIAMOND"
print RHOMBUS"
shape inputWhich shape do you want? upper
if shape :
shape "HEXAGON"
elif shape :
shape "CIRCLE"
elif shape :
shape "DIAMOND"
elif shape :
shape "RHOMBUS"
number intinputEnter a number from inclusive:
guess number colour, shape
if player.hascardguess:
if guess not in guessedcards:
printfThe player has the card guess
printGood guess!"
guessedcards.addguess
else:
printfThe player has the card guess
Step 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