Last active
April 20, 2020 08:31
-
-
Save briatte/c3319315873ff3aedb7976c83b8b5059 to your computer and use it in GitHub Desktop.
This file contains 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
# triangle.py | |
import math | |
def triangle_perimeter(a, b, c): | |
return a + b + c | |
def triangle_area(a, b, c): | |
p = triangle_perimeter(a, b, c) / 2 | |
x = math.sqrt(p * (p - a) * (p - b) * (p - c)) | |
return round(x, 2) | |
def main(): | |
a = input("Side 1:") | |
a = float(a) | |
b = input("Side 2:") | |
b = float(b) | |
c = input("Side 3:") | |
c = float(c) | |
print("Perimeter:", triangle_perimeter(a, b, c)) | |
print("Area:", triangle_area(a, b, c)) | |
if __name__ == "__main__": | |
main() | |
# kthxbye |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment