reso_deux_deg.py

Created by yann-rougeron

Created on June 09, 2024

645 Bytes

Résolution axcarre+bx+c. On donne a,b,c le programme renvoie: Si Delta posi, x1 et x2 Si Delta nul, x1 Si Delta negatif, pas de solution réelle


# Resolution equation 2nd degre
from math import *
print("ax^2+bx+c")
a=float(input('coefficient a: '))
b=float(input('coefficient b: '))
c=float(input('coefficient c: '))
delta=b**2-4*a*c
print("delta=",delta)
if delta>0:
  print("delta=b^2-4ac>0")
  x1=(-b+sqrt(delta))/(2*a)
  x2=(-b-sqrt(delta))/(2*a)
  print("Les deux racines sont:")
  print("x1=(-b+rac(delta))/2a")
  print("x1=",x1)
  print("x2=(-b-rac(delta))/2a")
  print("x2=",x2)
if delta==0:
  print("delta=b^2-4ac")
  x0=-b/(2*a)
  print("La racine double est:")
  print("x0=-b/2a=",x0)
if delta<0:
  print("delta=b^2-4ac<0")
  print("Pas de solution réelle")

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.