Funcions matemàtiques en Python | Conjunt 4 (Funcions i constants especials)
Algunes de les funcions matemàtiques es discuteixen a continuació al conjunt 1, conjunt 2 i conjunt 3 Funcions matemàtiques en Python | Conjunt 1 (funcions numèriques) Funcions matemàtiques en Python | Conjunt 2 (funcions logarítmiques i de potència) Funcions matemàtiques en Python | Conjunt 3 (funcions trigonomètriques i angulars) En aquest article es comenten les funcions i constants especials. 1. gamma() :- Aquesta funció s'utilitza per retornar el funció gamma of the argument. Python
2. pi :- Aquesta és una constant integrada que genera el valor de pi (3,141592) . 3. i :- Aquesta és una constant integrada que genera el valor de e(2,718281) . Python
4. inf :- Això és un constant infinit de coma flotant positiva . -inf s'utilitza per indicar l'infinit de coma flotant negatiu. Aquesta constant es defineix a Python 3.5 i posteriors. 5. Per a tu() :- Aquesta funció s'utilitza per comprovar si el valor és an infinit o no. 6. en :- Aquesta constant denota ' No un número 'en python. Aquesta constant es defineix a Python 3.5 i posteriors. 7. isnan() :- Torna aquesta funció cert si el nombre és 'nan' else returns false. 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 :- Aquesta és una constant integrada que genera el valor de pi (3,141592) . 3. i :- Aquesta és una constant integrada que genera el valor de 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 :- Això és un constant infinit de coma flotant positiva . -inf s'utilitza per indicar l'infinit de coma flotant negatiu. Aquesta constant es defineix a Python 3.5 i posteriors. 5. Per a tu() :- Aquesta funció s'utilitza per comprovar si el valor és an infinit o no. 6. en :- Aquesta constant denota ' No un número 'en python. Aquesta constant es defineix a Python 3.5 i posteriors. 7. isnan() :- Torna aquesta funció cert si el nombre és '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