¶ Exercise: Scope and Accumulation
- Go to the following directory path:
ch05
> exercises
- If not already present, create a new file:
scope.py
- Complete the following activity in
scope.py
- After completing the activity below:
- Make a commit (with any message you want)
- Push your changes back to GitHub.
Write the following functions:
- Write a function that multiplies two numbers together using a loop and accumulator (no multiplication) and return the resulting value
- Write a function that takes a number and exponent as parameters and raises the number to the exponent and return the resulting value (no exponentiation)
- Write another function, called square, that takes a single parameter and squares it by only calling your multiplication or exponent function and return the resulting value
only one line of code
Test your code by calling each function with whatever value you choose, then printing their results, i.e. the return value.