Complete the functions for the build test to pass
The functions should be shared among the team members such that each team member completes at least one function.
- One member of the team (Student A) should
fork
the repository - the other members should
fork
the repository from Student A - each student completes at least one function and sends a
pull request
to student A - student A should check and
merge
thepull request
- Once all the functions has been
merged
to student A's repository, the build will pass
- change the the
multiply
function inapp.py
to the following
@app.route('/multiply/<a>/<b>', methods=['GET'])
def multiply(a, b):
try:
a, b = float(a), float(b)
except ValueError:
return jsonify({'Value Error': "Only numbers Please"})
return jsonify({'result': a * b})
- change the the
add
function inapp.py
to the following
@app.route('/add/<a>/<b>', methods=['GET'])
def add(a, b):
try:
a, b = float(a), float(b)
except ValueError:
return jsonify({'Value Error': "Only numbers Please"})
return jsonify({'result': a + b})
- change the the
subtract
function inapp.py
to the following
@app.route('/subtract/<a>/<b>', methods=['GET'])
def subtract(a, b):
try:
a, b = float(a), float(b)
except ValueError:
return jsonify({'Value Error': "Only numbers Please"})
return jsonify({'result': a - b})
- change the the
divide
function inapp.py
to the following
@app.route('/divide/<a>/<b>', methods=['GET'])
def divide(a, b):
try:
a, b = float(a), float(b)
except ValueError:
return jsonify({'Value Error': "Only numbers Please"})
if b == 0:
return jsonify({'Value Error': "Cannot divide by zero"})
return jsonify({'result': a / b})
- change the the
modulus
function inapp.py
to the following
@app.route('/mod/<a>/<b>', methods=['GET'])
def modulus(a, b):
try:
a, b = float(a), float(b)
except ValueError:
return jsonify({'Value Error': "Only numbers Please"})
if b == 0:
return jsonify({'Value Error': "Cannot modulo by zero"})
return jsonify({'result': a % b})