def pyModule():
    # Modules refer to a file containing Python statements and definitions.
    # A file containing Python code, is called module
    # for example: pythonBasic.py, is called a module, and its module name would be pythonBasic
    # We use modules to break down large programs into small manageable and organized files
    # modules provide reusability of code.
    # We can define our most used functions in a module and import it, instead of copying their definitions into different programs
    import mathModule
    print(mathModule.add(10, 20))

    from mathModule import add
    print(add(10, 20))

    from mathModule import add as a
    print(a(10, 20))

    # from math import *;   import all method of module
    print(dir(mathModule))
    print(help(mathModule))
    print('name of module: ', mathModule.__name__
          )  # __name__ is special attribute which contain the name of module
예제 #2
0
import mathModule

addres = mathModule.add(100, 200)
print(addres)

subres = mathModule.sub(500, 200)
print(subres)

mulres = mathModule.mul(2, 3)
print(mulres)

divres = mathModule.div(10, 2)
print(divres)
예제 #3
0
import mathModule

mathModule.add(2, 5)
mathModule.sub(2, 5)
mathModule.mul(2, 5)
mathModule.div(2, 5)
mathModule.exp(2, 5)
예제 #4
0
import mathModule
print(mathModule.PI)
from mathModule import PI
print(PI)
from mathModule import *
print(PI)
print(locals())

import mathModule
print(mathModule.add(4, 9))
예제 #5
0
# -*- coding: utf-8 -*-
#import mathModule as mmod
#mmod.add(15,10)
#mmod.mult(15,10)
#
#print(mmod.customer["firstname"])

from mathModule import add
add(5, 7)