pythagorean_converse.py

Created by matt-numworks

Created on January 09, 2026

629 Bytes

This script runs the Pythagorean Converse to determine if a triangle is acute, obtuse, or right. If you use values that do not make a triangle, then it will also let you know the numbers cannot be a triangle.


#We want to determine if a triangle is right, acute, or obtuse
#Define a function for the sides of a triangle
def converse(a,b,c):
  sides = [a,b,c]
 
#sort the three inputs
  sortedSides = sorted(sides)

#is it a triangle
  if sortedSides[0]+sortedSides[1] <= sortedSides[2]:
    print("This is not a triangle.")

#is it acute, obtuse, or right
  elif sortedSides[0]**2 + sortedSides[1]**2 > sortedSides[2]**2:
    print("This triangle is acute.")
  elif sortedSides[0]**2 + sortedSides[1]**2 < sortedSides[2]**2:
    print("This triangle is obtuse.")
  else:
    print("This triangle is right.")



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.