In: Computer Science
def is_one_player_game(game_type)-> bool:
"""The parameter represents the type of game being played: human,
human-human,
or human-computer. The function should return True if and
only
if this is a one-player game.
"""
Python code(the given code is in python):
def is_one_player_game(game_type)->bool:
#checking if only one human is required
if(game_type=="human"):
#returning True
return True
#checking if two human is required
elif(game_type=="human-human"):
#returning False
return False
#checking if only one human and computer is
required
elif(game_type=="human-computer"):
#returning True
return True
#only this much is required, the below lines are for testing and
is for your understanding
#calling is_one_player_game function and printing result for
human-computer
print(is_one_player_game("human-computer"))
#calling is_one_player_game function and printing result for
human
print(is_one_player_game("human"))
#calling is_one_player_game function and printing result for
human-human
print(is_one_player_game("human-human"))
Screenshot:
Output: