Example #1
0
#from 패키지 import 모듈
from my_package import calculator

print(calculator.plus(10, 5))
print(calculator.minus(10, 5))
print(calculator.multiply(10, 5))
print(calculator.divide(10, 5))
Example #2
0
print(calculator.minus(10, 5))
print(calculator.multiply(10, 5))
print(calculator.divide(10, 5))
# 방법2.
# import  패키지명.모듈명
import my_package.calculator
print(my_package.calculator.plus(10,5))
print(my_package.calculator.minus(10,5))
print(my_package.calculator.multiply(10,5))
print(my_package.calculator.divide(10,5))
# 방법3.
# import  패키지명.모듈명  as 별칭명
import my_package.calculator  as cal
print(cal.plus(10,5))
print(cal.minus(10,5))
print(cal.multiply(10,5))
print(cal.divide(10,5))

# 외부 모듈파일 불러오기
import numpy as np
import pandas as pd

# 1차원 배열
a = np.array([1,2,3,4,5])
print(a)
# 1차원 배열 : 한가지 자료형으로 처리
b = np.array([1, 2.0, 3, 4, 5])
print(b)            # [1. 2. 3. 4. 5.]

# 그래프 그리기
import matplotlib.pyplot as plt
Example #3
0
from my_package import calculator as c

print(c.plus(10, 5))
print(c.minus(10, 5))
print(c.multiply(10, 5))
print(c.divide(10, 5))
Example #4
0
from my_package.calculator import plus
from my_package.calculator import multiply
from my_package.calculator import minus
from my_package.calculator import divide

print(plus(5, 1))  # 함수의 이름만으로 호출 가능
print(multiply(1, 2))
print(minus(1, 2))
print(divide(2, 4))
Example #5
0
from my_package import calculator

print(calculator.plus(10, 5))
print(calculator.minus(10, 5))
print(calculator.multiply(10, 5))
print(calculator.divide(10, 5))
Example #6
0
# 방법 1.
# from 패키지명 import 모듈명

from my_package import calculator

print(calculator.plus(10, 3))

# 방법 2
# import 패키지명.모듈명
import my_package.calculator

print(my_package.calculator.plus(10, 3))
# print(calculator.plus(10, 3))  # 방법 2로 할 시에는 패키지경로까지 모두 적어주어야 함.

# 방법 3
# import 패키지명.모듈명 as 별칭
import my_package.calculator as cal

print(cal.plus(10, 3))
print(cal.minus(10, 3))
print(cal.multiply(10, 3))
print(cal.divide(10, 3))

# 예제
import matplotlib.pyplot as plt

plt.plot([1, 2, 3, 5])
plt.ylabel('some numbers')
plt.show()