eq2degres.py

Created by squirreline

Created on April 22, 2018

605 Bytes

Une version un peu améliorée du script de base de Numworks “polynomial.py”


from math import *
# racines(a,b,c) determine les solutions de l'equation a*x**2+b*x+c=0
def racines(a,b,c):
  delta = b*b-4*a*c
  print("delta=",delta)
  if delta == 0:
    #donne la valeur exacte de la solution
    print ("x_0=","-",b,"/ 2 *",a,"=",-b/(2*a))
  elif delta > 0:
    x_1 = (-b-sqrt(delta))/(2*a)
    x_2 = (-b+sqrt(delta))/(2*a)
    #donne la valeur exacte de la solution
    print ("x_1=","( -",b,"- sqrt(",delta,")",")","/ 2 *",a,"=",x_1)
    print ("x_2=","( -",b,"+ sqrt(",delta,")",")","/ 2 *",a,"=",x_2)
  else:
    print ("pas de solutions reelles")
    
    
   

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.