STEP 2: Now that we ask for input before the functions, we can delete those lines from within the functions.

  • Within each function, delete the lines that .ask() for num_1 and num_2.
  • Add num_1, num_2 within each function definition, for example, def add(num_1, num_2):
  • Add num_1, num_2 as arguments within each function CALL, for example, add(num_1, num_2)

We are now asking for the numbers once, then passing them to the functions! We've refactored this program!

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)