0% found this document useful (0 votes)
11 views2 pages

Class 15 Math Module

The document discusses the math module in Python. It describes what a module is and lists some important functions in the math module like pi, sqrt, pow. It shows how to import the math module and access its functions. It also demonstrates importing specific functions from a module and using an alias.

Uploaded by

kunala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

Class 15 Math Module

The document discusses the math module in Python. It describes what a module is and lists some important functions in the math module like pi, sqrt, pow. It shows how to import the math module and access its functions. It also demonstrates importing specific functions from a module and using an alias.

Uploaded by

kunala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

codule:- Module is a part of python program,there are 2 type of module

2n-built module(os,sys,math etc)


2rd party module(pandas,numpy,scipy,matplotlib etc)

Mathematical Functions(math module)

module:- A module is collection of functions,classes nad variables etc.

print(dir(math))

acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'comb',


'copysign', 'cos', 'cosh', 'degrees', 'dist', 'e', 'erf', 'erfc', 'exp', 'expm1',
'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum', 'gamma', 'gcd', 'hypot',
'inf', 'isclose', 'isfinite', 'isinf', 'isnan', 'isqrt', 'lcm', 'ldexp', 'lgamma',
'log', 'log10', 'log1p', 'log2', 'modf', 'nan', 'nextafter', 'perm', 'pi', 'pow',
'prod', 'radians', 'remainder', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'tau',
'trunc', 'ulp']

ex:-
print(math.pi) # 3.141592653589793
print(math.sqrt(16)) # 4.0
print(math.pow(3,2)) # 9.0

Alias:-

emport math as m

once we create alias name,by using that we can access function and variable of that
module.

emport math as m

print(m.pi)gj
print(m.sqrt(25))ghj
print(m.sin(30))hj

particular member import:-

we can import a particular member of a module explicity using 'from' keyword.

from math import sqrt,pi

Note:- If we import a memeber explicity then it is not required to


use module name while accessing.

important functions of math module:-

cell(x)
floor(x)
pow(x,y)
factorial(x)
trunc(x)
gcd(x,y)
sin(x)
cos(x)
tan(x)

Q:- write a python program to find area of circle and r = 16?

ans:-
from math import pi
r = 16
print('area of circle is:',pi*r**2)

area of circle is: 804.247719318987

You might also like