Racine V2
Conditions d’achèvement
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 21 11:10:11 2017
@author: vmahout
"""
import math
def Quadri(a,b,c) :
Det = (b**2)-4*a*c
V1 = (-b-math.sqrt(Det))/(2*a)
V2 = (-b+math.sqrt(Det))/(2*a)
return (V1,V2)
def Quadribis(a,b,c) :
Det = (b**2)-4*a*c
if (Det >= 0) :
V1 = (-b-math.sqrt(Det))/(2*a)
V2 = (-b+math.sqrt(Det))/(2*a)
else :
V1 = -b/(2*a)
V2 = (math.sqrt(-Det))/(2*a)
return (V1,V2)
R1,R2 = Quadribis(1,2,4)
print('Les deux racines valent respectivement {0:.2f} et {1:.2f}'.format(R1,R2))