emulator for switch

script 305B

1234567891011121314151617
  1. # Solve the quadratic equation ax**2 + bx + c = 0
  2. # import complex math module
  3. import cmath
  4. a = 1
  5. b = 5
  6. c = 6
  7. # calculate the discriminant
  8. d = (b**2) - (4*a*c)
  9. # find two solutions
  10. sol1 = (-b-cmath.sqrt(d))/(2*a)
  11. sol2 = (-b+cmath.sqrt(d))/(2*a)
  12. print('The solution are {0} and {1}'.format(sol1,sol2))