Example Gist as exercise.
This is the description, and THIS FILE IS MANDATORY.
You can include your markdown description here.
{ | |
"numbers_1.json": "https://gist.githubusercontent.com/santiagobasulto/01ab0d95e6b54328e63d1e31f2c2ef1c/raw/e16bbb932edadb8863763af62deeb3e7eacf01ed/numbers_1.json", | |
"numbers_2.json": "https://gist.githubusercontent.com/santiagobasulto/01ab0d95e6b54328e63d1e31f2c2ef1c/raw/e16bbb932edadb8863763af62deeb3e7eacf01ed/numbers_2.json" | |
} |
1e864813-b40e-4cb2-a79d-f2370047e4be |
import json | |
def calculate_from_json(file_name): | |
pass |
""" | |
import json | |
with open("numbers_1.json") as fp: | |
print(json.load(fp)) | |
with open("numbers_2.json") as fp: | |
print(json.load(fp)) | |
""" | |
print(1 + 1) |
import json | |
def calculate_from_json(file_name): | |
with open(file_name) as fp: | |
data = json.load(fp) | |
a, b = float(data['a']), float(data['b']) | |
return a + b |
def test_file_1(): | |
assert calculate_from_json('numbers_1.json') == 9 | |
def test_file_2(): | |
assert calculate_from_json('numbers_2.json') == 3.5 |