math module in python

preview_player
Показать описание
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

• ceil(): This method rounds a number upwards to the nearest integer. If we provide a non-numeric parameter, it gives TypeError.
import math

• floor(): This method rounds a number downwards to the nearest integer.
import math

• trunc() : Takes a number as argument and returns the truncated integer part.
import math

• factorial(): Returns the factorial value of a given number.
import math

• 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

• sqrt() : This method returns square root of a given number.
import math

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.

#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
Рекомендации по теме
Комментарии
Автор

Could you help with this, I want to get a number from a interface (GUI) in Python, I entry 5.3 for example but when I try to multiple this entry by 2 it shows 0, I verifity the type of variable before multiple and it says is a float. here the code:


from tkinter import *

ventana = Tk()

ventana.geometry("500x80")



def send_data1():

e1 = float(entrada1.get())

entrada1.delete(0, END)

print (e1)



entrada1 = StringVar()


e1 = float()

entrada1 = Entry(ventana, width="8")

entrada1.place(x = 20, y = 8)

entrada1_entry = Entry(textvariable = entrada1)

boton1 = Button(ventana, text="data", command=send_data1, width="40", height="1", bg="#DC143C")

boton1.place(x=100, y=5)

ventana.mainloop()



print (2 * e1)

print(type(e1))



0.0

<class 'float'>

juank
Автор

You are right sir, like in Java we used to run a whole 'for' loop for finding factorial (RIP to the time, space complexity of it). Python fixes it all...

devanshusharma
visit shbcf.ru