1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| #! /usr/bin/env python
| # -*- coding: utf-8 -*-
|
| import cmath
|
| print("Programm zur Lösung einer quadratischer Gleichung ax^2 + bx + c = 0")
| a = float(input("a = "))
| b = float(input("b = "))
| c = float(input("c = "))
|
| determinant = b**2 - 4*a*c
| d = cmath.sqrt(determinant)
| x1 = (-b - d) / (2*a)
| x2 = (-b + d) / (2*a)
| print(f"Gleichung: {a}x^2 + {b}x + {c} = 0")
| print(f"x1 = {x1}")
| print(f"x2 = {x2}")
|
|