Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

from cap import Player, generate _ random _ hand, create _ deck def play ( player: Player ) - > None: print ( Welcome

from cap import Player, generate_random_hand, create_deck
def play(player: Player)-> None:
print("Welcome to Sleuth!")
questions_asked =0
incorrect_guesses =0
guessed_cards = set()
while len(guessed_cards)<3:
print("Would you like to:")
print("1. Ask a question.")
print("2. Guess a card.")
choice = input("Which option would you like? ")
if choice =="1":
questions_asked +=1
print("Which question would you like to ask?")
print("1. How many cards with a certain colour?")
print("2. How many cards with a certain shape?")
print("3. How many cards with a certain number?")
print("4. How many cards with a certain colour and number?")
print("5. How many cards with a certain shape and number?")
print("6. How many cards with a certain colour and shape?")
question_choice = input("Which option would you like? ")
if question_choice in ["1","4","6"]:
print("The colour options are:")
print("1. RED")
print("2. BLUE")
print("3. GREEN")
print("4. YELLOW")
colour = input("Which colour do you want? ").upper()
if colour =="1":
colour = "RED"
elif colour =="2":
colour = "BLUE"
elif colour =="3":
colour = "GREEN"
elif colour =="4":
colour = "YELLOW"
if question_choice in ["2","5","6"]:
print("The shape options are:")
print("1. HEXAGON")
print("2. CIRCLE")
print("3. DIAMOND")
print("4. RHOMBUS")
shape = input("Which shape do you want? ").upper()
if shape =="1":
shape = "HEXAGON"
elif shape =="2":
shape = "CIRCLE"
elif shape =="3":
shape = "DIAMOND"
elif shape =="4":
shape = "RHOMBUS"
if question_choice in ["3","4","5"]:
number = int(input("Enter a number from 1-4(inclusive): "))
if question_choice =="1":
count = player.count_cards(colour=colour)
print(f"The player has {count} cards with colour {colour}.")
elif question_choice =="2":
count = player.count_cards(shape=shape)
print(f"The player has {count} cards with shape {shape}.")
elif question_choice =="3":
count = player.count_cards(number=number)
print(f"The player has {count} cards with number {number}.")
elif question_choice =="4":
count = player.count_cards(colour=colour, number=number)
print(f"The player has {count} cards with colour {colour} and number {number}.")
elif question_choice =="5":
count = player.count_cards(shape=shape, number=number)
print(f"The player has {count} cards with shape {shape} and number {number}.")
elif question_choice =="6":
count = player.count_cards(colour=colour, shape=shape)
print(f"The player has {count} cards with colour {colour} and shape {shape}.")
else:
print("That is not an option, try again.")
elif choice =="2":
print("The colour options are:")
print("1. RED")
print("2. BLUE")
print("3. GREEN")
print("4. YELLOW")
colour = input("Which colour do you want? ").upper()
if colour =="1":
colour = "RED"
elif colour =="2":
colour = "BLUE"
elif colour =="3":
colour = "GREEN"
elif colour =="4":
colour = "YELLOW"
print("The shape options are:")
print("1. HEXAGON")
print("2. CIRCLE")
print("3. DIAMOND")
print("4. RHOMBUS")
shape = input("Which shape do you want? ").upper()
if shape =="1":
shape = "HEXAGON"
elif shape =="2":
shape = "CIRCLE"
elif shape =="3":
shape = "DIAMOND"
elif shape =="4":
shape = "RHOMBUS"
number = int(input("Enter a number from 1-4(inclusive): "))
guess =(number, colour, shape)
if player.has_card(guess):
if guess not in guessed_cards:
print(f"The player has the card {guess}.")
print("Good guess!")
guessed_cards.add(guess)
else:
print(f"The player has the card {guess}.")

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

Students also viewed these Databases questions