0

I'm new to this site, I'm recently trying to learn how to code in Python again, and now I'm doing an exercise that I could complete, but it's happening something that is annoying me. I can import math successfully, but somehow, VSCode just doesn't want to recognize "from math import sqrt". Here's my code so anyone can help me. Thank you.

import math  # (from math import sqrt would be here, but doesn't work so I put import math)

a = int(input('Digite o primeiro número: '))
b = int(input('Digite o segundo número: '))

c = a**2+b**2
resultado = math.sqrt(c)

print(f'O comprimento da hipotenusa é de {resultado}')
Matthias
  • 12,873
  • 6
  • 42
  • 48

2 Answers2

0

If you do from math import sqrt then you have imported only sqrt and not math. So in this case resultado = math.sqrt(c) should be resultado = sqrt(c) instead.

Mathias answered it in the comments; thank you.

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
0

you dont need the math module, you can instead do:

c = (a**2+b**2)**0.5

as square rooting a number is equal to power it to 1/2.

Guinther Kovalski
  • 1,629
  • 1
  • 7
  • 15