Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started