Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pythagorean theorem python

    distance = math.sqrt((abs(distancex) ** 2) + (abs(distancey) ** 2))
Comment

pythagoras theorem formula

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)
Comment

Pythagorean theorem

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);
    }
}
Comment

pythagoras theorem formula in python

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()
Comment

pythagoras theorem

// 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,"?"));
Comment

PREVIOUS NEXT
Code Example
Python :: defining function in python 
Python :: Palindrome in Python Using while loop for string 
Python :: embed python discord 
Python :: how to open annaconda 
Python :: append to list at index python 
Python :: program to demonstrate encapsulation in python 
Python :: python dataframe add rank column 
Python :: if condition in python lambda 
Python :: save set of numpy arrays to file py 
Python :: Convert Int to String Using format() method 
Python :: hierarchy dendrogram 
Python :: python random.sample 
Python :: how to find duplicates in csv file using python 
Python :: sort function in pandas dataframe to sort specific properties 
Python :: python remove first item in list 
Python :: plot histogram from counts and bin edges 
Python :: pandas remove multi header from dataframe 
Python :: drf serializer 
Python :: numpy cumsum 
Python :: parse_dates 
Python :: local time in python 
Python :: pyside click through window 
Python :: random.randint(0,20) + pyrthon 
Python :: dockerize django 
Python :: dynamically create python dictionary 
Python :: dictionary input from user in python3 
Python :: name is not defined python 
Python :: one-hot encode categorical variables standardize numerical variables 
Python :: check package is installed by conda or pip environment 
Python :: how add a favicon to django 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =