EXERCISE 5: This program has 3 different functions that are almost the same. Let's refactor it to use one function.

  • Create a new function and name it fly. Delete the old functions.
  • The new function should take in two parameters: fly_height to control how high the toucan flies and fly_type so that the toucan can tell us how high he's flying.
  • Use the new function to have the toucan do the same series of flights as before: high, high, low, medium, low.

To navigate the page using the TAB key, first press ESC to exit the code editor.

# THIS ACTIVITY IS IN PREVIEW ONLY MODE
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)