#!/usr/bin/python
# -*- coding: utf-8 -*-
# Author: yeshengwei
# E-mail: [email protected]

import module1
import module2

# 调用模块1的方法
module1.say_hello()

# 调用模块2的方法
module2.say_hello()

dog = module1.Dog()

cat = module2.Cat()
예제 #2
0
import module1
import math


def say_hello(name):
    print("You smell bad", name)


def sqrt():
    print("......")


print(module1.var1)

module1.say_hello("Aria")

from module1 import say_hello

say_hello("Aria")

print(math.ceil(3.5))
print(math.isnan(3))
print(math.modf(3.5))
print(math.pow(2, 3))
print(math.sin(0))

from math import sqrt

print(sqrt(4))
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Author: yeshengwei
# E-mail: [email protected]

# 一次性导入模块中的所有工具
import module1 as Md1
import module2 as Md2

# 使用模块别名调用方法
Md1.say_hello()
# 使用模块别名调用方法
Md2.say_hello()
예제 #4
0
import module1 as DogModule
import module2 as CatModule

DogModule.say_hello()
CatModule.say_hello()

dog1 = DogModule.Dog()
cat1 = CatModule.Cat()

print(dog1)
print(cat1)
예제 #5
0
import module1
from module1 import say_hello
from math import sqrt


print(module1.var1)

name = 'Sam'


def say_hello(name):
    print(name, 'smells bad!')


def sqrt(num):
    return num**0.5


say_hello(name)
say_hello('Tim')
print(sqrt(9))
예제 #6
0
파일: main.py 프로젝트: kaiwencaiwen/IBCS
import module1
import math
from module1 import say_hello
from math import sqrt
print(module1.var1)


def say_hello(name):
    print("you smell bad " + name)


say_hello("tom")

# Q9 the one in main

# Q10
print(math.ceil(2.5))
print(math.copysign(5.0, -2))
print(math.fabs(-6.0))
print(math.factorial(4))
print(math.floor(2.5))

# Q11


def sqrt(num):
    return num * num


print(sqrt(5))
# it uses the one created in main
예제 #7
0
    print()


#Q5


#Q7
#Module1 code
def say_hello(string):
    print(string)


#main code
import module1

module1.say_hello("hello")


#Q8
#Module 1 code:
def say_hello(string):
    print(string)


#Main code:
from module1 import say_hello

say_hello('Tom')
#Q9

#10
예제 #8
0
import module1
# print(module1.x)
module1.say_hello('bob')

import random
print(random.randint(1, 10))

# bad practice - polluting your own namespace
# from module1 import *
# print(x)
# say_hello('joe')

# import random
# random.randint(1, 10)

# import package1.module3
# print(package1.module3.y)

# from package1 import module3
# print(module3.y)

# from package1 import module3 as m3
# print(m3.y)