-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexo2.py
More file actions
39 lines (35 loc) · 1.08 KB
/
exo2.py
File metadata and controls
39 lines (35 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# -*-coding:latin-1 -*
import os
a = 0
b = 0
c = 0
D = 0
a = input("saisissez votre nombre: ")
a = float( a )
b = input("saisissez votre nombre:")
b = float( b )
c = input("saisissez votre nombre:")
c = float( c )
D = ((b**2) - (4*a*c))
if((a == 0 and b == 0) and c == 0):
print("pas d'équation")
elif(a == 0 and (b != 0 and c!= 0)):
print("il s'agit d'une équation du 1er degrée et nn d'une éqution du 2nd , on va donc calculer la seule solution de : bx + c = 0 ")
print( (-c)/b )
else:
if(D < 0):
print("pas de solution réelle")
elif D == 0:
print("on a une solution double x0")
print( (-b)/(2*a) )
else:
print("vous avez bien deux soulutions réelles et distinctes")
if b < 0:
X1 = X1 = ((-b) + sqrt(D))/(2*a)
X2 = X2 = c/a/X1
print(" les solutions sont : \n X1 =", X1, "\n X2 = ", X2 )
else:
X1 = X1 = ((-b) - sqrt(D))/(2*a)
X2 = X2 = c/a/X1
print( "les solutions sont : X1 =", ((-b) - sqrt(D))/(2*a), "\n X2=", c/(a*(((-b) - sqrt(D))/(2*a))) )
os.system("pause")