Monday, May 24, 2010

Pythagorean Theorem

If you are on school and you are taking algebra like me or just want to find the missing length of one side of the triangle than this program should help you out. Pythagorean Theorem is great and extremely essay to use.
We can find the side of a triangle using the Pythagorean algorithm. This uses the Python programming language.

def menu():
      #print the options you have
      print " "
      print "Welcome to Pythagorean Theorem"
      print "Please keep in mind that for this program to work you need the lenght of two side of the triangle"
      print " "
      print "Your Options Are:"
      print " "
      print "1) If you have the lenght of A and B"
      print " "
      print "2) If you have the lenght of C and A"
      print " "
      print "3) If you have the lenght of C and B"
      print " "
      print "4) Quit Pythagorean Theorem"
      print " "
      return input ("Choose your option: ")

from math import *
      #On this one we have the lenght of A and B and we are trying to find the lenght of C
def AnB(a,b):
      print a**2, "+", b**2, "=", a**2 + b**2
      print sqrt(a**2 + b**2)
      #On this one we have the lenght of A and C and we are trying to find the lenght of B
def CnA(c,a):
      print c**2, "-", a**2, "=", c**2 - a**2
      print sqrt(c**2 - a**2)
      #On this one we have the lenght of B and C and we are trying to find the lenght of A
def CnB(c,b):
      print c**2, "-", b**2, "=", c**2 - b**2
      print sqrt(c**2 - b**2)
      #Code is Run
loop = 1
choice = 0
while loop == 1:
      choice = menu()
      if choice == 1:
            AnB(input("A: "),input("B: "))
      elif choice == 2:
            CnA(input("C: "),input("A: "))
      elif choice == 3:
            CnB(input("C: "),input("B: "))
      elif choice == 4:
            loop = 0
print "Thankyou fo using Pythagorean Theorem"
Honest Face

3 comments:

  1. pusiiing kalo bahas ginian gan.. :D

    btw GW dah FOLLOW gan.. ats nm WONG.. NGantian ya.. thx ;)

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. THanks bro,......klo lama lama ga pusing bro

    ReplyDelete