def main(): #Uses import add_module print(add_module.add(3,6)) #Uses from add_module import add print(add(4,5)) #Uses from add_module import add as add2 print(add2(1,3))
def main(): x = add_module.add(3, 4) # Uses import add_module print(x) y = add(1, 3) # Uses from add_module import add, conflict with local add print(y) z = a_func(5, 6) print(z) # Uses from add_module import add as a_func
from cyt_module import subtract from add_module import add sol = subtract(4.5, 2) print(sol) print(add(1000, 5000))
add_module.py dm ├── div_module.py ├── extra │ ├── pow_module.py │ └── sub_module.py └── mul_module.py ''' import sys sys.path.append('/Users/deep.cloud2208/HDD/Training/temp/') import add_module from dm.div_module import div from dm.extra import sub_module as sm import dm.extra.sub_module x = add_module.add(10,100) y = div(31,7) z = sm.sub(100,10) # print(sys.path) # print(" ") # print("x ---> ",x) import pymongo # print(dir(pymongo)) # print(globals()) # print(id(x)) # print(hash(x)) # print(max([10,100,1000,2000,400])) # print(min([10,100,1000,2000,400]))
import sys import add_module print(add_module.add(float(sys.argv[1]), float(sys.argv[2])))
import add_module a=input("Enter the value of A :") b=input("Enter the value of B :") print "Addition of A and B is "+add_module.add(a,b)
#!/bin/python3.6 import add_module print(add_module.msg) r = add_module.add(10, 20) print('add=', r) ## method 2 of importing module import add_module as am print(am.msg) r = am.add(20, 30) print('add r2', r) ## method 3 of import from add_module import msg print(msg) # no need fo prefix add_module.msg ##4 from add_module import * print(msg) r = add(100, 200) print('r=', r) ##5 from add_module import msg as m print(m) ## Package import net.cloud.add_module print(net.cloud.add_module.msg)
import add_module print(add_module.add(100, 200)) # 300
def test_add_strings(self): result = add('Hello,', ' World!') self.assertEquals('Hello, World!', result)
def test_add_integers(self): result = add(3, 5) self.assertEquals(8, result)
import argparse import add_module parser = argparse.ArgumentParser() parser.add_argument('a', type=float) parser.add_argument('b', type=float) args = parser.parse_args() print(add_module.add(args.a, args.b))