logo

Matematinės funkcijos Python | 4 rinkinys (specialiosios funkcijos ir konstantos)

Kai kurios matematinės funkcijos yra aptariamos toliau pateiktuose 1 rinkiniuose 2 ir 3 rinkiniuose Matematinės funkcijos Python | 1 rinkinys (skaitinės funkcijos) Matematinės funkcijos Python | 2 rinkinys (logaritminės ir galios funkcijos) Matematinės funkcijos Python | 3 rinkinys (trigonometrinės ir kampinės funkcijos) Šiame straipsnyje aptariamos specialiosios funkcijos ir konstantos. 1. gama () :- Ši funkcija naudojama grąžinti gama funkcija of the argument. Python
# Python code to demonstrate the working of # gamma() # importing 'math' for mathematical operations import math a = 4 # returning the gamma() of 4 print ('The gamma() of 4 is : ' end='') print (math.gamma(a)) 
Output:
The gamma() of 4 is : 6.0 

2. pi :- Tai yra įmontuota konstanta, kuri išveda pi(3,141592) reikšmė . 3. ir :- Tai yra įmontuota konstanta, kuri išveda e vertė (2,718281) . Python
# Python code to demonstrate the working of # const. pi and e # importing 'math' for mathematical operations import math # returning the value of const. pi print ('The value of const. pi is : ' end='') print (math.pi) # returning the value of const. e print ('The value of const. e is : ' end='') print (math.e) 
Output:
The value of const. pi is : 3.141592653589793 The value of const. e is : 2.718281828459045 

4. inf :- Tai a teigiama slankiojo kablelio begalybės konstanta . -inf naudojamas neigiamai slankiojo kablelio begalybei žymėti. Ši konstanta yra apibrėžta python 3.5 ir naujesnėje versijoje. 5. Tau () :- Ši funkcija naudojama patikrinti ar reikšmė yra an begalybė ar ne. 6. in :- Ši konstanta reiškia Ne skaičius ' Python'e. Ši konstanta yra apibrėžta python 3.5 ir naujesnėje versijoje. 7. isnan() :- Ši funkcija grąžinama tiesa, jei skaičius yra „nan“ else returns false. Python
# Python code to demonstrate the working of # inf nan isinf() isnan() # importing 'math' for mathematical operations import math # checking if number is nan if (math.isnan(math.nan)): print ('The number is nan') else : print ('The number is not nan') # checking if number is positive infinity if (math.isinf(math.inf)): print ('The number is positive infinity') else : print ('The number is not positive infinity') 
Output:
The number is nan The number is positive infinity