Unit3 Modules
Unit3 Modules
Unit3 Modules
Pre-defined modules
Importing libraries
In [30]:
import math
from math import pi
from math import *
from math import pi as p
import math as m
In [31]:
print(math.pi)
print(pi)
print(pi)
print(p)
print(m.pi)
3.141592653589793
3.141592653589793
3.141592653589793
3.141592653589793
3.141592653589793
In [105]:
<class 'module'>
In [42]:
['__doc__', '__loader__', '__name__', '__package__', '__spec__', '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', 'isn
an', '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']
This module provides access to the mathematical functions
defined by the C standard.
<class '_frozen_importlib.BuiltinImporter'>
math
In [45]:
print(help(math))
NAME
math
DESCRIPTION
This module provides access to the mathematical functions
defined by the C standard.
FUNCTIONS
acos(x, /)
Return the arc cosine (measured in radians) of x.
acosh(x, /)
Return the inverse hyperbolic cosine of x.
asin(x, /)
R t th i ( d i di ) f
In [55]:
import numpy
help(numpy)
NAME
numpy
DESCRIPTION
NumPy
=====
Provides
1. An array object of arbitrary homogeneous items
2. Fast mathematical operations over arrays
3. Linear Algebra, Fourier Transforms, Random Number Generation
In [46]:
Collecting python-math
Downloading python_math-0.0.1-py3-none-any.whl (2.4 kB)
Installing collected packages: python-math
Successfully installed python-math-0.0.1
In [51]:
import math
In [52]:
In [53]:
import aas
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_16552/2605444043.py in <module>
----> 1 import aas
User-defined modules
In [106]:
import simplemaths
simplemaths.pi
Out[106]:
3.14
In [92]:
In [107]:
import simplemaths as s
print(type(s))
<class 'module'>
In [108]:
Strings.lowercase("PYTHON")
Out[108]:
'python'
In [90]:
In [109]:
st.uppercase("python")
Out[109]:
'PYTHON'
In [111]:
s.add(10,30,40,50)
Out[111]:
130
In [112]:
s.sub(10,20)
Out[112]:
-10
In [113]:
s.pow(2,3)
Out[113]:
In [104]:
class Sample:
a = 10
b = 20
@staticmethod
def display():
return print(Sample.a,Sample.b)
if __name__=='__main__':
s = Sample()
s.display()
10 20
In [ ]: