Created
March 15, 2022 16:45
-
-
Save dnsouzadev/91f549bb87faf85971cda7db166c3fa5 to your computer and use it in GitHub Desktop.
Script pra calcular a formula Heron
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
from math import sqrt | |
def calcula_area(a, b, c): | |
try: | |
s = 0.5 * (a + b + c) | |
res = sqrt(s * (s - a) * (s - b) * (s - c)) | |
res = round(res, 2) | |
return f"A área desse triângulo é {res} metros quadrados" | |
except ValueError: | |
return "Error!!" | |
def main(): | |
print("") | |
print("Fórmula de Héron") | |
try: | |
a = int(input("Primeiro Lado: ")) | |
b = int(input("Segundo Lado: ")) | |
c = int(input("Terceiro Lado: ")) | |
print(calcula_area(a, b, c)) | |
except: | |
print("Apenas inteiros/erro") | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment