Skip to main content

Featured

What is Coroutine in Android?

Coroutines are available for the Kotlin language. Coroutines are simply cooperative functions.   Our Android applications often have multiple concurrent and interdependent functionalities. We provide instructions to the system through code, also known as a program, to perform a set of sequential instructions.  During the execution of these instructions, a specific instruction may take longer than expected, causing the next line of code to wait until the previous line of code has completed its execution. This scenario is known as blocking program execution. To avoid blocking program execution, the code must be executed on a separate thread. A thread is a single sequential flow of control. However, creating and handling multiple threads can be difficult and expensive in terms of OS operations and memory usage. To address this issue, we can use Coroutines in Kotlin. Coroutines are cooperative functions that are executed on threads as needed in a cooperative manner. They help...

Python Mathematical Functions

Hello All,
In this post we will come to know about some Mathematical functions which are very useful python.

There are so many functions available in python but here I am listing some of them. You can find more functions on python website.

Functions :
  1. abs()
  2. math.ceil()
  3. math.floor()
  4. math.exp()
  5. sqrt()
  6. math.log()
  7. max()
  8. min()
  9. round()
  10. math.modf()
  11. pow()
1.abs(number) :
This function  return absolute value of a number. Function takes one argument as parameter and return absolute value of that.
try out some line of code by yourself and find out usage of abs() function.


2.math.ceil(number) :
This function return upper bound value for the given number as parameter. This function takes one argument as parameter and return Ceiling Value for that number. To use this function we have to import math module of python.

try out some example to get better understanding about this.


3. math.floor(number) :
This function return lower bound value for the given number as parameter. This function takes one argument as parameter and return Floor value for that number. To use this function we have to import math module of python.



4.math.exp(number) :
This function is for calculation of e^number. where number is what you passed to this function and value of e is approximately equals to 2.71828...



5.math.sqrt(number) :
This function return the square root of passed value as parameter. For value < 0 , this function will not work and give you error for that. So make sure that you are passing positive value only for appropriate output



6.math.log(number,[base]) :
This function takes 2 argument as parameter but 2nd parameter base is optional. That means if you don't pass base as argument then this function will compute natural logarithm of number else will give output for logarithm of given base for that number.



7.max(num1,num2,num3,...) :
This function will give us maximum number as output from given numbers as parameter to this function. This function also finds out max number from given list instead of passing values as , separated. Check out example code for that :



8.min(num1,num2,num3,...) :
This function will return return minimum from given number of parameters to the function.You can also pass list as parameter to find out minimum value among them.



9.round(number,number of digits) :
Round function round off the given number to desired number of digits. If we don't provide the value for number of digits for round off then it will return nearest integer value.



10.math.modf(number) :
This function is very handy if you want to break down fraction numbers. Function takes a number as input and return tuple as result which contains the fraction and non-fractional part.



11.pow(number,power) :
Function takes 2 parameter as input number and power and return the power of the number as output.



These are some commonly used Mathematical functions in python. There are many more mathematical functions you can find out more functions on python website.

If you find this post interesting and helpful then please share it with your friends.

Comments

Popular Posts