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.
This exercise is part of the course
Writing Functions in Python
Exercise instructions
- Add the functions
std()
,minimum()
, andmaximum()
to thefunction_map
dictionary, 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 passdata
as an argument.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# 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)