Session Ready
Exercise

Creating associative arrays

Associative arrays are powerful constructs to use in your Bash scripting. They are very similar to 'normal' arrays, however they have a few important differences in their creation, manipulation and key properties.

Associative arrays allow you to index using words rather than numbers, which can be important for ease of inputting and accessing properties. For example, rather than accessing 'index 4' of an array about a city's information, you can access the city_population property, which is a lot clearer!

In this exercise we will practice creating and adding to an associative array. We will then access some special properties that are unique to associative arrays. Let's get started!

NOTE: if you submit incorrect code, you may need to refresh the browser to remove old variables etc that affect the test suite before submitting again

Instructions 1/3
undefined XP
  • 1
  • 2
  • 3
  • Create an empty associative array on one line called model_metrics. Do not add any elements to it here.
  • Add the following key-value pairs; (model_accuracy, 98), (model_name, "knn"), (model_f1, 0.82).