filmov
tv
Modules in Python

Показать описание
A group of function, variables and classes saved to a file, which is nothing but module. Every python file (.py) is nothing but a module.
There are two types of modules: (1.) Predefined modules (2) user defined module
User defined module means we have to create our own module and use them whenever we need them.
Once the module is created, any developer in the project team can use that module .
Advantages:
1. Reusability: code can be reuse
2. Save the time
def add(a,b):
return a+b
def sub(a,b):
return a-b
def mul(a,b):
return a*b
def div(a,b):
return a/b
import cal
#a,b=(int(x)for x in input("enter 2 numbers:").split())
a=int(input("enter a value "))
b=int(input("enter a value "))
print(c)
print(d)
"""output:
enter a value 4
enter a value 6
10
0.6666666666666666
"""
There are two types of modules: (1.) Predefined modules (2) user defined module
User defined module means we have to create our own module and use them whenever we need them.
Once the module is created, any developer in the project team can use that module .
Advantages:
1. Reusability: code can be reuse
2. Save the time
def add(a,b):
return a+b
def sub(a,b):
return a-b
def mul(a,b):
return a*b
def div(a,b):
return a/b
import cal
#a,b=(int(x)for x in input("enter 2 numbers:").split())
a=int(input("enter a value "))
b=int(input("enter a value "))
print(c)
print(d)
"""output:
enter a value 4
enter a value 6
10
0.6666666666666666
"""