logo

Funkcje matematyczne w Pythonie | Zestaw 4 (funkcje specjalne i stałe)

Niektóre funkcje matematyczne omówiono poniżej w zestawie 1, zestawie 2 i zestawie 3 Funkcje matematyczne w Pythonie | Zestaw 1 (funkcje numeryczne) Funkcje matematyczne w Pythonie | Zestaw 2 (funkcje logarytmiczne i potęgowe) Funkcje matematyczne w Pythonie | Zbiór 3 (funkcje trygonometryczne i kątowe) W tym artykule omówiono funkcje specjalne i stałe. 1. gamma() :- Ta funkcja służy do zwracania funkcja gamma 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 :- Jest to wbudowana stała, która wyprowadza wartość pi(3,141592) . 3. i :- Jest to wbudowana stała, która wyprowadza wartość e(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 :- To jest dodatnia stała nieskończoności zmiennoprzecinkowa . -inf służy do oznaczenia ujemnej nieskończoności zmiennoprzecinkowej. Ta stała jest zdefiniowana w Pythonie 3.5 i nowszych wersjach. 5. Dla Ciebie() :- Ta funkcja jest używana sprawdzać czy wartość jest nieskończoność, czy nie. 6. w :- Ta stała oznacza ' Nie liczba ' w Pythonie. Ta stała jest zdefiniowana w Pythonie 3.5 i nowszych wersjach. 7. isnan() :- Ta funkcja zwraca prawda, jeśli liczba to „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