Building a command line data app
You are building a command line tool that lets a user interactively explore a dataset. We've defined four functions: mean(), std(), minimum(), and maximum() that users can call to analyze their data. Help finish this section of the code so that your users can call any of these functions by typing the function name at the input prompt.
Note: The function get_user_input() in this exercise is a mock version of asking the user to enter a command. It randomly returns one of the four function names. In real life, you would ask for input and wait until the user entered a value.
Latihan ini adalah bagian dari kursus
Writing Functions in Python
Petunjuk latihan
- Add the functions
std(),minimum(), andmaximum()to thefunction_mapdictionary, like we did withmean(). - The name of the function the user wants to call is stored in
func_name. Use the dictionary of functions,function_map, to call the chosen function and passdataas an argument.
Latihan interaktif praktis
Cobalah latihan ini dengan menyelesaikan kode contoh berikut.
# Add the missing function references to the function map
function_map = {
'mean': mean,
'std': ____,
'minimum': ____,
'maximum': ____
}
data = load_data()
print(data)
func_name = get_user_input()
# Call the chosen function and pass "data" as an argument
____[____](data)