equation_second_degre.py

Created by benjamin-demassieux

Created on April 19, 2018

433 Bytes

Permet de résoudre une équation du second degré dans l’ensemble des nombres réels.


import math
def discriminant(a,b,c):
  delta=b**2-4*a*c
  return(delta)
  
def n_solution(a,b,c):
  d=discriminant(a,b,c)
  if d>0:
    return('2 solutions reelles')
  elif d==0:
    return('1 solution reelles')
  elif d<0:
    return('pas de solutions reelles')
    
def solution(a,b,c):
  if delta>0:
    x1=(-b+sqr(delta)/(2*a))
    x2=(-b-sqr(delta)/(2*a))
    solutions=[x1,x2]
    return(solutions)

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.