Skip to content

Instantly share code, notes, and snippets.

@dnsouzadev
Created March 15, 2022 16:45
Show Gist options
  • Save dnsouzadev/91f549bb87faf85971cda7db166c3fa5 to your computer and use it in GitHub Desktop.
Save dnsouzadev/91f549bb87faf85971cda7db166c3fa5 to your computer and use it in GitHub Desktop.
Script pra calcular a formula Heron
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