pythagore.py

Created by 1epauletteshark

Created on January 03, 2024

1.99 KB


from math import sqrt

def hypothenuse(t,a,b,u="cm"):
  print("-"*43)
  print("Le triangle {} est rectangle en {} donc,".format(t,t[1]))
  print("dapres le theoreme de Pythagore on a:")
  print("-"*43)
  print("{}^2 = {}^2 + {}^2".format(t[0]+t[2],t[:2],t[1:]))
  print("{} = {}{} et {} = {}{}".format(t[:2],a,u,t[1:],b,u))
  print("-"*43)
  print("{}^2 = {}^2 + {}^2".format(t[0]+t[2],a,b))
  print("{}^2 = {} + {}".format(t[0]+t[2],a**2,b**2))
  print("{}^2 = {}".format(t[0]+t[2],a**2+b**2))
  print("{} = sqrt({})".format(t[0]+t[2],a**2+b**2))
  print("soit {} = {}{}".format(t[0]+t[2],sqrt(a**2+b**2),u))
  print("-"*43)

def longueur(t,h,a,u="cm"):
  print("-"*43)
  print("Le triangle {} est rectangle en {} donc,".format(t,t[1]))
  print("dapres le theoreme de Pythagore on a:")
  print("-"*43)
  print("{}^2 = {}^2 - {}^2".format(t[1:],t[0]+t[2],t[:2]))
  print("{} = {}{} et {} = {}{}".format(t[0]+t[2],h,u,t[:2],a,u))
  print("-"*43)
  print("{}^2 = {}^2 - {}^2".format(t[1:],h,a))
  print("{}^2 = {} - {}".format(t[1:],h**2,a**2))
  print("{}^2 = {}".format(t[1:],h**2-a**2))
  print("{} = sqrt({})".format(t[1:],h**2-a**2))
  print("soit {} = {}{}".format(t[1:],sqrt(h**2-a**2),u))
  print("-"*43)

def reciproque(t,h,a,b,u="cm"):
  print("-"*43)
  print("Dune part {} = {}^2 = {}".format(t[0]+t[2],h,h**2))
  print("Dautre part {} + {} = {}^2 + {}^2 = {}".format(t[:2],t[1:],a,b,a**2+b**2))
  print("-"*43)
  if h**2==a**2+b**2:
    print("donc dapres la reciproque du theoreme")
    print("de Pythagore, le triangle {} est".format(t))
    print("rectangle en {}".format(t[1]))
  else:
    print("donc dapres la contraposee du theoreme")
    print("de Pythagore, le triangle {} nest".format(t))
    print("pas rectangle".format(t[1]))

print("-"*43)
print("hypothenuse(t,u,a,b)")
print("longueur(t,u,h,a)")
print("reciproque(t,u,h,a,b)")
print("-"*43)
print('t = nom du triangle #"ABC"')
print("h = hypothenuse #5")
print('u = unite #"cm"')
print("a = longueur 1")
print("b = longueur 2")
print("-"*43)

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.