Search
Solve the problems in PRO-HW-01.pdf:
Upload a zip archive hw01.zip (via the course ware) containing:
hw01.zip
hw01.json
hw01.py
hw01.pdf
Note: All files must be contained in the root of hw01.zip.
The file hw01.json will be evaluated automatically, while hw01.py and hw01.pdf will be evaluated manually.
Creating hw01.json:
Create an empty dictionary in Python:
solution = {}
The keys for this dictionary will be “task1”, “task2”, “task3” (for task 3.b) and “task4”.
“task1”
“task2”
“task3”
“task4”
The value for the key “task1” is the list of coefficients of the product polynomial starting from the term of the highest degree, i.e. for the product polynomial 2*x^4 + 5*x^3 + 3*x^2 + 1 do
2*x^4 + 5*x^3 + 3*x^2 + 1
solution["task1"] = [2, 5, 3, 0, 1]
The value for the key “task2” is the list of lists of coefficients of the quotient polynomial and the remainder, respectively, starting from the term of the highest degree, i.e. for the quotient polynomial 2*x^3 + 1 and the remainder x + 2 do
2*x^3 + 1
x + 2
solution["task2"] = [[2, 0, 0, 1], [1, 2]]
The value for the key “task3” is the list of roots to the polynomial from task 3.b (including multiplicities), i.e. for the sequence of roots 1, 1, 2, 3 do
1, 1, 2, 3
solution["task3"] = [1, 1, 2, 3]
The value for the key “task4” is created in the same way as for the key “task3”.
Finally, save solution to hw01.json:
solution
import json with open("hw01.json", "w") as outfile: json.dump(solution, outfile)