Добавить
Уведомления

math module in python

In this video you will learn about various functions of math module in python. math module python The math module is a built in module in python. It provides mathematical functions. To use its functions we have to import it. The commonly used methods of math module are as follows: • fabs(): This methods removes – sign from a number and returns positive float equivalent of that number. Gives TypeError if we provide a parameter which is not a number. import math print(math.fabs(-2.3))#prints 2.3 print(math.fabs(-3))#prints 3.0 print(math.fabs("t"))#TypeError • ceil(): This method rounds a number upwards to the nearest integer. If we provide a non-numeric parameter, it gives TypeError. import math print(math.ceil(2.3))#prints 3 print(math.ceil(-3.4))#prints -3 print(math.ceil("t"))#TypeError • floor(): This method rounds a number downwards to the nearest integer. import math print(math.floor(2.3))#prints 2 print(math.floor(-3.4))#prints -4 print(math.floor("t"))#TypeError • trunc() : Takes a number as argument and returns the truncated integer part. import math print(math.trunc(2.3))#prints 2 print(math.trunc(-3.4))#prints -3 print(math.trunc("t"))#TypeError • factorial(): Returns the factorial value of a given number. import math print(math.factorial(3))#prints 6 print(math.factorial(-3.4))#ValueError print(math.factorial("t"))#TypeError • gcd() : This method returns the highest value that can divide two integers. This is known as greatest common divisor or highest common factor. import math print(math.gcd(2,12))#prints 2 print(math.gcd(0,12))#prints 12 print(math.gcd(0,0))#prints 0 print(math.gcd(3.5,4))#TypeError print(math.gcd("t","a"))#TypeError • sqrt() : This method returns square root of a given number. import math print(math.sqrt(4))#prints 2 print(math.sqrt(-4))#ValueError print(math.sqrt("t"))#TypeError The math module also provides several mathematical constants like pi, tau , e , nan, and inf etc. The module also provides several methods like cos(), sin(), tan() , cosh(), sinh(), tanh(), exp(), log and many more. For more details you can go to the following official python 3 documentation. https://docs.python.org/3/library/math.html #python_by_tarun_sir #tarun_sir #python #tarun_sir_python #python_video_57 #math_module_in_python #python_tutorial #factorial_function_in_python #gcd_function_in_python

Иконка канала JavaScript С Основами
22 подписчика
12+
17 просмотров
2 года назад
12+
17 просмотров
2 года назад

In this video you will learn about various functions of math module in python. math module python The math module is a built in module in python. It provides mathematical functions. To use its functions we have to import it. The commonly used methods of math module are as follows: • fabs(): This methods removes – sign from a number and returns positive float equivalent of that number. Gives TypeError if we provide a parameter which is not a number. import math print(math.fabs(-2.3))#prints 2.3 print(math.fabs(-3))#prints 3.0 print(math.fabs("t"))#TypeError • ceil(): This method rounds a number upwards to the nearest integer. If we provide a non-numeric parameter, it gives TypeError. import math print(math.ceil(2.3))#prints 3 print(math.ceil(-3.4))#prints -3 print(math.ceil("t"))#TypeError • floor(): This method rounds a number downwards to the nearest integer. import math print(math.floor(2.3))#prints 2 print(math.floor(-3.4))#prints -4 print(math.floor("t"))#TypeError • trunc() : Takes a number as argument and returns the truncated integer part. import math print(math.trunc(2.3))#prints 2 print(math.trunc(-3.4))#prints -3 print(math.trunc("t"))#TypeError • factorial(): Returns the factorial value of a given number. import math print(math.factorial(3))#prints 6 print(math.factorial(-3.4))#ValueError print(math.factorial("t"))#TypeError • gcd() : This method returns the highest value that can divide two integers. This is known as greatest common divisor or highest common factor. import math print(math.gcd(2,12))#prints 2 print(math.gcd(0,12))#prints 12 print(math.gcd(0,0))#prints 0 print(math.gcd(3.5,4))#TypeError print(math.gcd("t","a"))#TypeError • sqrt() : This method returns square root of a given number. import math print(math.sqrt(4))#prints 2 print(math.sqrt(-4))#ValueError print(math.sqrt("t"))#TypeError The math module also provides several mathematical constants like pi, tau , e , nan, and inf etc. The module also provides several methods like cos(), sin(), tan() , cosh(), sinh(), tanh(), exp(), log and many more. For more details you can go to the following official python 3 documentation. https://docs.python.org/3/library/math.html #python_by_tarun_sir #tarun_sir #python #tarun_sir_python #python_video_57 #math_module_in_python #python_tutorial #factorial_function_in_python #gcd_function_in_python

, чтобы оставлять комментарии