distance = math.sqrt((abs(distancex) ** 2) + (abs(distancey) ** 2))
import math
class point:
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
p1 = point(10,14,0)
p2 = point(14,14,0)
distanceByTwoPoints = math.sqrt((p1.y-p2.y)**2 + (p1.x-p2.x)**2)
public class PythagoreanTheorem {
public static void main(String args[]) {
double a=4;
double b=5;
double c = Math.sqrt(a * a + b * b);
System.out.println("c = " + c);
}
}
import math
print("
")
print("_____________________Pythagorean Theorem with Python__________________________________")
print("___________________________created by THARCHEN________________________________________")
print("
")
print("Please note the following indications
")
print("a is the base of the triangle
")
print("b is the height of the triangle
")
print("c is the hypotenus of the triangle
")
side = input("Give the side you want to solve for (a, b, or c): ")
if side == "a":
print("
")
print("Let us find the base of the triangle
")
b = float(input("Height: "))
c = float(input("Hypotenuse: "))
a = math.sqrt(c ** 2 - b ** 2)
print("Base of the triangle is", "%.2f" %a)
print("
")
elif side == "b":
print("Let us find the height of the triangle
")
a = float(input("Base: "))
c = float(input("Hypotenuse: "))
b = math.sqrt(c ** 2 - a ** 2)
print("Height of the triangle is","%.2f" %b)
elif side == "c":
print("Let us find the hypotenuse of the traingle
")
a = float(input("Base: "))
b = float(input("Height: "))
c = math.sqrt(a ** 2 + b ** 2)
print("Hypotenuse of the triangle is","%.2f" %c)
else:
print("The value of hypotenuse is always greater than height and base")
def triangle():
print(" .")
print(" /|")
print(" / |")
print(" / |")
print(" / |")
print(" / |")
print(" / |")
print(" / |")
def traingle_1():
print(" ","%.2f" %c, " ","%.2f" %b)
def triangle_2():
print(" / |")
print(" / |")
print(" / |")
print(" / |")
print(" / |")
print(" / |")
print("/___","%.2f"%a,"____|
")
triangle()
traingle_1()
triangle_2()
// Formula
// a^2 + b^2 = c^2
// base as a leg
// altitude as b leg
// hypotenuse as c leg
function pythagorean(base,altitude,hypotenuse) {
if (base=== "?") {
let bSqure= altitude*altitude
let cSqure= hypotenuse*hypotenuse
let aSqure= cSqure - bSqure
return Math.sqrt(aSqure)
}
if (altitude === "?") {
let aSqure= base*base
let cSqure= hypotenuse*hypotenuse
let bSqure= cSqure - aSqure
return Math.sqrt(bSqure)
}
if (hypotenuse === "?") {
return Math.sqrt( base*base + altitude*altitude)
}
}
console.log(pythagorean("?",5,13));
console.log(pythagorean(6,8,"?"));
console.log(pythagorean(3,4,"?"));
console.log(pythagorean('?',8,16));
console.log(pythagorean(5,5,"?"));