Beispiel #1
0
#导入m1和m2
import m1
import m2 as abc

num1 = input("请输入第一个数:")
num2 = input("请输入第二个数:")
num1 = float(num1)
num2 = float(num2)

#调用模块m1中的模块成员
m1.add(num1, num2)
m1.sub(num1, num2)

yuanzhoulv = m1.PI
print("圆周率:", yuanzhoulv)
print("城市:", m1.city)

#对模块m2中的类Calc实例化
c = abc.Calc()
x = c.mul(num1, num2)
print("相乘结果:", x)
print("相除结果:", c.div(num1, num2))
Beispiel #2
0
import m1
print(m1.add(100, 20))
print(__name__)
Beispiel #3
0
#vd8: Module
import m1
print(m1.add(2, 3))
print(m1.PI)

#Cach 2
from m1 import add
from m1 import PI

print(add(2, 3))
print(PI)

#Built-in modules
import math
print(math.sqrt(9))
Beispiel #4
0
from m1 import add, sub
from m1 import PI, city
from m2 import Calc

num1 = input("请输入第一个数:")
num2 = input("请输入第二个数:")
num1 = float(num1)
num2 = float(num2)
add(num1, num2)
sub(num1, num2)

c = Calc()
x = c.mul(num1, num2)
print("两数相乘结果:", x)
y = c.div(num1, num2)
print("两数相除结果:", y)
Beispiel #5
0
from m1 import add, pi
import math

print(math.exp(1))

print(add(3, 5))