""" Slightly extended version of exercise 5.1 from "Excercises for IN1900". Before we compute and print the roots, we check that they exist and use an if-elif-else clause to control the computation and the output. """ import numpy as np a = float(input("Skriv in a: ")) b = float(input("Skriv in b: ")) c = float(input("Skriv in c: ")) D = b**2 - 4 * a * c if D < 0: print("Ingen reelle nullpunkter") elif D == 0: x = - b / (2 * a) print(f"Ett nullpunkt, x = {x}") else: x1 = (-b - np.sqrt(b**2 - 4 * a * c)) / (2 * a) x2 = (-b + np.sqrt(b**2 - 4 * a * c)) / (2 * a) print(f"To nullpunkter, x1 = {x1}, x2 = {x2}") """ Terminal> python quadratic_input.py Skriv in a: 1 Skriv in b: 1 Skriv in c: 1 Ingen reelle nullpunkter python quadratic_input.py Skriv in a: 1 Skriv in b: 2 Skriv in c: 1 Ett nullpunkt, x = -1.0 """