# -----------------------------------------+ # Your name | # CSCI 107, Assignment 5 | # Last Updated: Month Day, Year | # -----------------------------------------| # This program simulates a Magic 8 Ball, | # providing responses to user questions | # based on a number they enter. | # -----------------------------------------+ # -----------------------------------------+ # TODO: get_question # -----------------------------------------+ # Returns: A boolean, True if the user entered yes, False if not. # -----------------------------------------+ # This function prompts the user to enter # a yes/no question for the Magic 8 Ball. # -----------------------------------------+ def get_question(): return # -----------------------------------------+ # TODO: get_roll # -----------------------------------------+ # Returns: An integer, the number entered by the user. # -----------------------------------------+ # This function prompts the user to enter a # number between 1 and 20 and validates the input. # -----------------------------------------+ def get_roll(): return # -----------------------------------------+ # TODO: affirmative_response # -----------------------------------------+ # Parameters: A int value for the roll. # Returns: A string, an affirmative response. # -----------------------------------------+ # This function returns one of the affirmative # responses based on the roll value. # -----------------------------------------+ def affirmative_response(): return # -----------------------------------------+ # TODO: non_committal_response # -----------------------------------------+ # Parameters: A int value for the roll. # Returns: A string, a non-committal response. # -----------------------------------------+ # This function returns one of the non-committal # responses based on the roll value. # -----------------------------------------+ def non_committal_response(): return # -----------------------------------------+ # TODO: negative_response # -----------------------------------------+ # Parameters: A int value for the roll. # Returns: A string, a negative response. # -----------------------------------------+ # This function returns one of the negative # responses based on the roll value. # -----------------------------------------+ def negative_response(): return # -----------------------------------------+ # TODO: shake_8ball # -----------------------------------------+ # Parameters: A int value for the roll. # Returns: a message containing the 8ball response # -----------------------------------------+ # This function selects the appropriate function call # based on the number entered by the user. # e.g affirmative_response(), non_committal_response(), or negative_response() # -----------------------------------------+ def shake_8ball(): response = "" message = "--> Magic 8 Ball says: " + response return message # -----------------------------------------+ # main # -----------------------------------------+ # The main function that runs the program, # orchestrating the input and output flow. # -----------------------------------------+ def main(): print("Welcome to the Magic 8 Ball!") question = get_question() if question: roll = get_roll() print(shake_8ball(roll)) # -----------------------------------------+ main()