0
Data type of Ļ ??š¤š¤
In which data type does Ļ come in ? Because it can be written in both rational and irrational forms ?
4 Answers
+ 1
Actually pi is not a rational number, we commonly use 22/7 or 3.14 for approximate but it can't be replaced pi
To use pi in python, we use 'math' module
Code --
from math import pi
print(pi)
The syntax is same for numpy or script
Code--
From numpy import pi
Print(pi)
Code--
From scipy import pi
Print(pi)
It will show you at float type as it is an irrational number (non repeating non terminating) but it stops after 8 or 16 places as there is a limit set there that a float data type can store only certain bytes .
This also applies to 'e' and other irrational numbers.
In these three modules, the value of pi is same.
Exactly equals to 3.141592653589793
+ 8
Ļ has never been a rational number. Its precise value cannot be expressed in decimal or binary number system, as computers work. So we can only approximate it.
The pi available in the math library, is a float type. You can check like this:
import math
print(math.pi)
print(type(math.pi))
There are also other libraries that give a representation of pi. numpy and scipy use the same value as the math library.
However, sympy uses a different value.
https://stackoverflow.com/questions/12645547/should-i-use-scipy-pi-numpy-pi-or-math-pi
+ 2
Aryan Raj Patel Value of Ļ come in float datatype
+ 1
Oh thanks!