racine_trinome.py

Created by hugocarloni84

Created on October 05, 2024

441 Bytes

Fonction pour trouver les racines d’un trinôme du second degrés.


from math import *
def r():
  a = float(input("Donner la valeur de a:\t"))
  b = float(input("Donner la valeur de b:\t"))
  c = float(input("Donner la valeur de c:\t"))
  
  d = b**2-4*a*c
  
  if d < 0:
    print("Il n'y a pas de racine")
  
  elif d == 0:
    x0 = (-b)/(2*a)
    print("La racine est ",x0)
  
  else :
    x1 = (-b-sqrt(d))/(2*a)
    x2 = (-b+sqrt(d))/(2*a)
    print("Les racines sont",x1,"\net",x2)

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.