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 :: pyton do while loop+ 
Python :: reverse array python 
Python :: get all different element of both list python 
Python :: django admin.py 
Python :: python chat 
Python :: enumerate in range python 
Python :: how to install python library 
Python :: django trim string whitespace 
Python :: swap in python 
Python :: pandas df describe() 
Python :: pandas nat to null? 
Python :: Read the entire text file using the read() function 
Python :: python logistic function 
Python :: python code to get wifi 
Python :: python includes string 
Python :: python socket get client ip 
Python :: how to add custom prefix in discord.py 
Python :: add 1 to all columns in numpy array 
Python :: selenium save page as image 
Python :: text from xml doc in python 
Python :: hex to string python 
Python :: how to use drf permission class with class method actions 
Python :: series astype 
Python :: how to find a prime number 
Python :: scaling pkl file? 
Python :: python To find the sum of all the elements in a list. 
Python :: tqdm command that works both in notebook and lab 
Python :: unsplash python 
Python :: create column with values mapped from another column python 
Python :: turtle graphics documentation|pensize 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =