import sys # modify this path to match your environment sys.path.append('C:\Users\mdriscoll\Documents') import mymath print(mymath.add(4, 5)) print(mymath.division(4, 2)) print(mymath.multiply(10, 5)) print(mymath.squareroot(48))
#!/usr/bin/python import sys sys.path.append('/home/za/dev/github/py101') import mymath print mymath.add(10,5) print mymath.multiply(10,5) print mymath.subtract(10,5) print mymath.division(10,5)
import mymath as division result = division.division(20, 10) print(result)
import mymath print(str(mymath.division(4, 2)))
# encoding=utf-8 import random, os # 1、实现自己的数学模块mymath,提供有4个函数,分别为加减乘除, # 在B模块中调用A模块的函数。 # 把当前的py文件当做B模块,mymath作为A模块 import mymath print mymath.add(1, 2) print mymath.division(2, 4) print mymath.ride(4, 8) print mymath.sub(9, 3) # 2、实现自己的字符串模块mystr,里面有方法:isdigit,strip, # join,split import mystr str3 = '\n\t abc ccc\n\t ' print mystr.Strip(str3) str4 = '*bay *bay*' print mystr.Strip(str4, '*') print mystr.Split('bbog bog bogbb', 'bb', -2) print mystr.Join(['abc', 'xyz', 'glory road']) print mystr.Join(['abc', '123', 'oj'], '*') print mystr.Isdigit('109') #老师的方法在mystr_01 # 3、构建一个模块的层级包 # 在当前的目录下面建立和当前文件同级的package:p1, # 在p1下面建立两个模块分别为,p11和p12, import p1
import sys # modify this path to match your environment sys.path.append('C:\Users\mdriscoll\Documents') import mymath print(mymath.add(4,5)) print(mymath.division(4, 2)) print(mymath.multiply(10, 5)) print(mymath.squareroot(48))