Module #4 Assignment

Problem 1: Roots

from math import sqrt


a = 1
b = -5.86
c = 8.5408

print(f"The quadratic equation is {a}*x^2 {b}*x + {c}")
x1 = (-b + sqrt(b**2 - 4*a*c))/(2*a)
x2 = (-b - sqrt(b**2 - 4*a*c))/(2*a)
print("The square root of the quadratic equation is:", x1, x2)

The quadratic equation is 1*x^2 -5.86*x + 8.5408
The square root of the quadratic equation is: 3.1400000000000006 2.7199999999999998

Problem 2: Reciprocals

decimal_list = [1/2, 1/3, 1/4, 1/5, 1/6, 1/7, 1/8, 1/9, 1/10]

for number in decimal_list:
print()
print(round(float(number), 2))

0.5

0.33

0.25

0.2

0.17

0.14

0.12

0.11

0.1

Comments