Question: 2 Linear Equation If a = 0, the earlier formula for the roots are invalid due to division by zero. Nevertheless, the equation remains valid:

 2 Linear Equation If a = 0, the earlier formula forthe roots are invalid due to division by zero. Nevertheless, the equation

2 Linear Equation If a = 0, the earlier formula for the roots are invalid due to division by zero. Nevertheless, the equation remains valid: bx+c= 0. Exercise Improve the function get_roots to return the root - if a = 0. Hint: Solution template: def get_roots(a, b, c): d = b**2 - 4 * a * # discriminant if roots = elif math.isclose(d, 6): roots = # repeated root else: d **= 0.5 roots = return roots In [ ]: def get_roots(a, b, c): d = b**2 - 4 * a *c # YOUR CODE HERE raise Not ImplementedError() return roots executed in 8ms, finished 15:16:42 2020-09-30 3 Degenerate Cases What if a = b = 0? In that case, the equation becomes c=0 which is always satisfied if c = 0, but never satisfied if c +0. Exercise Improve the function get_roots to return root(s) under all cases: . If a = 0 and b = 0, assign roots to the single root- If a = b = 0 and c 0, assign roots to None. Note that None is an object, not a string. . If a= brc=0, there are infinitely many roots. Assign to roots the tuple -float('inf'), float('inf'). Note that float('inf') converts the string 'inf' to a floating point value that represents o Hint: Use nested if statements such as the followings (with the blanks filled in properly): def get_roots(a, b, c): d = b**2 - 4 * a * if if if roots = -float('inf'), float('inf) else: roots = None else: elif math.isclose(d, 6): roots = # repeated root else: d ** 0.5 roots = return roots In [ ]: def get_roots(a, b, c): d = b**2 4 * a *c # YOUR CODE HERE raise Not ImplementedError() return roots executed in 10ms, finished 15:17:00 2020-09-30

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!