Python'da Matematiksel Fonksiyonlar | Set 1 (Sayısal Fonksiyonlar)

Python'da, görevlerimizi kolaylaştıran çeşitli işlevleri tanımlayan 'matematik' adlı bir modülün içe aktarılmasıyla bir dizi matematiksel işlem kolaylıkla gerçekleştirilebilir. 1. tavan() : - Bu fonksiyon şunu döndürür: sayıdan büyük en küçük integral değeri . Sayı zaten tam sayı ise aynı sayı döndürülür. 2. kat() : - Bu fonksiyon şunu döndürür: sayıdan küçük en büyük integral değeri . Sayı zaten tam sayı ise aynı sayı döndürülür. 

Python
   # Python code to demonstrate the working of    # ceil() and floor()    # importing 'math' for mathematical operations    import   math   a   =   2.3   # returning the ceil of 2.3    print   (  'The ceil of 2.3 is : '     end  =  ''  )   print   (  math  .  ceil  (  a  ))   # returning the floor of 2.3    print   (  'The floor of 2.3 is : '     end  =  ''  )   print   (  math  .  floor  (  a  ))   

Çıkış:

The ceil of 2.3 is : 3 The floor of 2.3 is : 2 

Zaman Karmaşıklığı: Ç(1)

Yardımcı Alan: Ç(1)


3. muhteşem() : - Bu fonksiyon şunu döndürür: mutlak değer numaranın. 4. faktöriyel() : - Bu fonksiyon şunu döndürür: faktöriyel numaranın. Sayı tamsayı değilse bir hata mesajı görüntülenir. 

Python
   # Python code to demonstrate the working of    # fabs() and factorial()    # importing 'math' for mathematical operations    import   math   a   =   -  10   b  =   5   # returning the absolute value.    print   (  'The absolute value of -10 is : '     end  =  ''  )   print   (  math  .  fabs  (  a  ))   # returning the factorial of 5    print   (  'The factorial of 5 is : '     end  =  ''  )   print   (  math  .  factorial  (  b  ))   

Çıkış:

The absolute value of -10 is : 10.0 The factorial of 5 is : 120 

Zaman Karmaşıklığı: O(b)

Yardımcı Alan: Ç(1)


5. kopya imzası(a b) :- Bu fonksiyon, sayıyı içeren sayıyı döndürür. 'a' değeri ancak 'b' işaretiyle . Döndürülen değer float tipindedir. 6.gcd() : - Bu fonksiyon hesaplamak için kullanılır 2 sayının en büyük ortak böleni argümanlarında dile getirildi. Bu işlev python 3.5 ve üzeri sürümlerde çalışır. 

Python
   # Python code to demonstrate the working of    # copysign() and gcd()    # importing 'math' for mathematical operations    import   math   a   =   -  10   b   =   5.5   c   =   15   d   =   5   # returning the copysigned value.    print   (  'The copysigned value of -10 and 5.5 is : '     end  =  ''  )   print   (  math  .  copysign  (  5.5     -  10  ))   # returning the gcd of 15 and 5    print   (  'The gcd of 5 and 15 is : '     end  =  ''  )   print   (  math  .  gcd  (  5    15  ))   

Çıkış:

The copysigned value of -10 and 5.5 is : -5.5 The gcd of 5 and 15 is : 5 

Zaman Karmaşıklığı: O(dak(cd))

Yardımcı Alan: Ç(1)