STEP 8: Let's finish the add() function!

  • From drop Addition indented inside the add() function.
  • Change the variable name from my_var to total. Change the 2 to num_1 and the 3 to num_2.
  • From GRAPHICS add Say. Change the string to "The sum is " + str(total).

We're using string concatenation to join "The sum is " and total. str() casts total from a float to a string!

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)