def dispatcher(command, arg): """ Does things >>> dispatcher("weather", "berkeley") Here's the weather forcast for berkeley >>> dispatcher("square", 2) The square of 2 is 4 >>> dispatcher("go away", 3) It sounds like you no longer need my assistance Very well. Goodbye! """ if command == "weather": print("Here's the weather forcast for "+arg) print(apis.fetch_weather(arg)) if command == "square": print("The square of " + arg + " is " + str(square(int(arg)))) elif command == "go away": print("It sounds like you no longer need my assistance") print("Very well. Goodbye!") return elif command == "bye": print("Goodbye! Have a good day!") return # Reprompt the user. prompter()
def dispatcher(command, arg): """ Does things """ if command == "weather": print("Here's the weather forcast for "+arg) weather_data = apis.fetch_weather(arg) if type(weather_data) is dict and weather_data[arg]: # assume non-zero termperature at berkeley print(apis.fetch_weather(arg)) if command == "square": print("The square of " + arg + " is " + str(square(int(arg)))) elif command == "go away": print("It sounds like you no longer need my assistance") print("Very well. Goodbye!") return elif command == "bye": print("Goodbye! Have a good day!") return # Reprompt the user. prompter()
def dispatcher(command, arg): """ Does things """ if command == "weather": print("Here's the weather forcast for " + arg) print(apis.fetch_weather(arg)) if command == "square": print("The square of " + arg + " is " + str(square(int(arg)))) elif command == "go away": print("It sounds like you no longer need my assistance") print("Very well. Goodbye!") return elif command == "bye": print("Goodbye! Have a good day!") return # Reprompt the user. prompter()
def dispatcher(command, arg): """ Does things """ command = command.upper() #Case does not matter if command == "WEATHER": print("Here's the weather forcast for "+arg) print(apis.fetch_weather(arg)) if command == "SQUARE": print("The square of " + arg + " is " + str(square(int(arg)))) elif command == "GO AWAY": print("It sounds like you no longer need my assistance") print("Very well. Goodbye!") return elif command == "BYE": print("Goodbye! Have a good day!") return # Reprompt the user. prompter()
def dispatcher(command, arg): """Checks implements command and then reprompts the user. If command is weather, dispatcher prints weather forcast for arg. If command is square dispatcher prints the arg and square of arg. If command is go away it exits dispatcher function with a passive aggressive goodbye message. If command is bye exits with pleasant farewell.""" if command == "weather": print("Here's the weather forcast for "+arg) print(apis.fetch_weather(arg)) if command == "square": print("The square of " + arg + " is " + str(square(int(arg)))) elif command == "go away": print("It sounds like you no longer need my assistance") print("Very well. Goodbye!") return elif command == "bye": print("Goodbye! Have a good day!") return # Reprompt the user. prompter()