Created
November 3, 2020 19:06
-
-
Save FMudanyali/1fb46d0398c62b39ba6170dd72903090 to your computer and use it in GitHub Desktop.
simple python script to calculate areas of quadrangle and parallelogram
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def dikdortgen_alan(point1, point2, point3, point4): | |
| """ | |
| * * * 2 * * *\n | |
| * * * * * * *\n | |
| 1 * * * * * 4\n | |
| * * * * * * *\n | |
| * * * 3 * * *\n | |
| kenar1 * kenar2\n | |
| pisagor teoremi der ki sqrt(a^2 + b^2) = c\n | |
| kenar1 => nokta2 x - nokta1 x = a, nokta2 y - nokta1 y = b\n | |
| kenar2 => nokta4 x - nokta3 x = a, nokta4 y - nokta3 y = b | |
| """ | |
| side1 = ((point2[0] - point1[0]) ** 2 + (point2[1] - point1[1]) ** 2 ) ** 0.5 | |
| side2 = ((point4[0] - point3[0]) ** 2 + (point4[1] - point3[1]) ** 2 ) ** 0.5 | |
| return round(side1 * side2, 2) | |
| def paralel_alan(point1, point2, point3, point4): | |
| """ | |
| * * 2 * * * * * 3\n | |
| * * * * * * * * *\n | |
| * * * * * * * * *\n | |
| 1 * * * * * 4 * *\n | |
| Taban * Yukseklik\n | |
| nokta2 y - nokta1 y = yukseklik\n | |
| nokta4 x - nokta1 x = taban | |
| """ | |
| height = point2[1] - point1[1] | |
| bottom = point4[0] - point1[0] | |
| return round(height * bottom, 2) | |
| print( | |
| dikdortgen_alan( | |
| [0,5], [5,10], [5,0], [10,5] | |
| ) | |
| ) | |
| print( | |
| paralel_alan( | |
| [0,0], [3,7], [13,7], [10,0] | |
| ) | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment