Completing the addition function and using a module

Report a typo

There's an unfinished Python module named 'arithmetic.py'. In the module, there are functions to perform the addition and subtraction of two numbers. The add function is incomplete. Fill in the gaps of the code given to you to make the add function work as expected. Remember, each function should return the calculated result in string format, followed by a newline character. In your 'main.py' script, import the 'arithmetic' module and call each function with any two numbers, printing out the results.

Fill in the gaps with the relevant elements
# File: .py
 add(a, b):
     str(a + b) + "\n"

def subtract(a, b):
    return str(a - b) + "\n"

# File: main.py
import arithmetic

print(arithmetic.add(5, 3))
print(arithmetic.subtract(10, 4))
defclassarithmeticmathreturnyield

Create a free account to access the full topic