- 첫 번째 셀: %%writefile calculator.py 아래에 계산기 기능 함수를 정의합니다. 이 셀을 실행하면 Colab 환경에 calculator.py 파일이 생성됩니다.
- 두 번째 셀: import calculator를 사용해 모듈을 가져옵니다.
- 각 함수(add, subtract, multiply, divide)를 호출하여 다양한 연산을 수행하고 결과를 확인합니다.
더보기
%%writefile calculator.py
def add(x, y):
return x + y
def subtract(x, y):
return x - y
def multiply(x, y):
return x * y
def divide(x, y):
return x / y
import calculator as cal
x = 18
y = 6
print(cal.add(x, y))
print(cal.subtract(x, y))
print(cal.multiply(x, y))
print(cal.divide(x,y))
#
24
12
108
3.0
'QAQC 부트캠프 퀘스트' 카테고리의 다른 글
[2025/01/08 ~ 2025/01/14]기초 프로젝트 - 친환경 차량 성능 데이터 분석 (0) | 2025.01.14 |
---|---|
[2025/01/03]Library 개인 과제 (1) | 2025.01.03 |
[2024/12/26]Python 개인 과제 (0) | 2024.12.26 |
[2024/12/20]온보딩 주차 KPT 회고 (0) | 2024.12.20 |
[2024/12/13]QA/QC 사전캠프 2일차 퀘스트 - 데이터 톺아보기(걷기반) (1) | 2024.12.13 |