Matematiska funktioner i Python | Set 4 (Specialfunktioner och konstanter)

Några av de matematiska funktionerna diskuteras nedan i set 1 set 2 och set 3 Matematiska funktioner i Python | Set 1 (numeriska funktioner) Matematiska funktioner i Python | Set 2 (logaritmiska och kraftfunktioner) Matematiska funktioner i Python | Set 3 (trigonometriska och vinkelfunktioner) Specialfunktioner och konstanter diskuteras i den här artikeln. 1. gamma() :- Denna funktion används för att returnera gammafunktion 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 :- Detta är en inbyggd konstant som matar ut värde på pi(3,141592) . 3. och :- Detta är en inbyggd konstant som matar ut värde på 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 :- Det här är en positiv flyttals oändlighetskonstant . -inf används för att beteckna den negativa flyttalsoändligheten. Denna konstant definieras i python 3.5 och högre. 5. För dig() :- Denna funktion används för att kontrollera om värdet är an oändlighet eller inte. 6. in :- Denna konstant betecknar ' Inte ett nummer ' i python. Denna konstant definieras i python 3.5 och högre. 7. isnan() :- Denna funktion returnerar sant om siffran är '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