Google News
logo
SciPy - Interview Questions
Explain Constants in SciPy
The scipy.constant package is available with a wide range of constants, which is used extensively in the scientific field. There are various physical, mathematical constants and units that we can import the required constants and use them as per needed.
 
The scipy.constant provides the following list of mathematical constants.
* pi
* golden
 
Here we compare the 'pi' value by importing different modules.
 
#Import pi constant from the scipy   
from scipy.constants import pi  
#Import pi from math package  
from math import pi  
#Comparing these two pi value  
print("sciPy - pi Value = %.18f"%scipy.constants.pi)  
print("math - pi Value = %.18f"%math.pi) 
 
Output :
 
sciPy - pi Value = 3.141592653589793116
math - pi Value = 3.141592653589793116

 

Advertisement