-2
from math import sin, pi
print(sin(2*pi)) 

This code includes the value of sin(2pi) which equals to 0, but why python show this -2.4492935982947064e-16? and how to fix it? Is it just the problem of my computer?

DeepSpace
  • 78,697
  • 11
  • 109
  • 154
KKR
  • 9
  • 4

1 Answers1

1

pi is not equal with π. you can use sympy instead.

from sympy import sin, pi
print(sin(pi))  # 0
SMortezaSA
  • 589
  • 2
  • 15