1
- #Code by MASTER-FURY
2
- def discriminant (a , b , c ):
3
-
4
- discriminant = (b ** 2 ) - (4 * a * c )
5
- if discriminant > 0 :
6
-
7
- print ('Discriminant is' , discriminant ,
8
- "which is Positive" )
9
-
10
- print ('Hence Two Solutions' )
11
-
12
- elif discriminant == 0 :
13
-
14
- print ('Discriminant is' , discriminant ,
15
- "which is Zero" )
16
-
17
- print ('Hence One Solution' )
18
-
19
- elif discriminant < 0 :
20
-
21
- print ('Discriminant is' , discriminant ,
22
- "which is Negative" )
23
-
24
- print ('Hence No Real Solutions' )
25
-
26
- # Driver Code
27
- a = 20
28
- b = 30
29
- c = 10
30
- discriminant (a , b , c )
1
+ # Code by MASTER-FURY
2
+ # and Matlmr
3
+
4
+ from math import sqrt
5
+
6
+ def discriminant (a , b , c ):
7
+
8
+ if a == 0 and b == 0 :
9
+
10
+ print ('This is a Constant' )
11
+
12
+ print ('Hence No Solution' )
13
+
14
+ elif a == 0 :
15
+
16
+ print ('This is a Linear Equation' )
17
+
18
+ print ('Hence One Solution: {}' .format (- c / b ))
19
+
20
+ else :
21
+
22
+ discriminant = (b ** 2 ) - (4 * a * c )
23
+
24
+ if discriminant > 0 :
25
+
26
+ print ('Discriminant is {} which is Positive' .format (discriminant ))
27
+
28
+ print ('Hence Two Solutions: {} and {}' .format ((- b + sqrt (discriminant )) / (2 * a ),
29
+ (- b - sqrt (discriminant )) / (2 * a )))
30
+
31
+ elif discriminant == 0 :
32
+
33
+ print ('Discriminant is {} which is Null' .format (discriminant ))
34
+
35
+ print ('Hence One Solution: {}' .format (- b / (2 * a )))
36
+
37
+ else :
38
+
39
+ print ('Discriminant is {} which is Negative' .format (discriminant ))
40
+
41
+ print ('Hence No Real Solutions' )
42
+
43
+ print ('There a Two Complex roots : {} and {}' .format (complex (- b , - sqrt (- discriminant )) / (2 * a ),
44
+ complex (- b , + sqrt (- discriminant )) / (2 * a )))
45
+
46
+ # Driver Code
47
+ a = 2
48
+ b = 2
49
+ c = 2
50
+ discriminant (a , b , c )
0 commit comments