当前位置:网站首页>Put functions in modules
Put functions in modules
2022-07-05 13:01:00 【South Lake Fishing Song】
# ------------- compute.py ---------------------------
def add(x,y):
return x + y
def sub(x,y):
return x - y
def mul(x,y):
return x * y
def div(x,y):
return x / y
# ------------- main.py ---------------------------
import compute as cp
print(cp.add(3,5))
print(cp.sub(3,5))
print(cp.mul(3,5))
print(cp.div(3,5))
from compute import add,sub,mul,div
print(add(3,5))
print(sub(3,5))
print(mul(3,5))
print(div(3,5))
from compute import * # Not recommended
print(add(3,5))
print(sub(3,5))
print(mul(3,5))
print(div(3,5))
边栏推荐
- Transactions from January 14 to 19, 2022
- [cloud native] use of Nacos taskmanager task management
- What if wechat is mistakenly sealed? Explain the underlying logic of wechat seal in detail
- Talk about my drawing skills in my writing career
- Detailed explanation of navigation component of openharmony application development
- SAP UI5 DynamicPage 控件介紹
- A few years ago, I outsourced for four years. Qiu Zhao felt that life was like this
- Introduction to sap ui5 dynamicpage control
- leetcode:221. 最大正方形【dp状态转移的精髓】
- Insmod prompt invalid module format
猜你喜欢
946. Verify stack sequence
SAP ui5 objectpagelayout control usage sharing
Laravel文档阅读笔记-mews/captcha的使用(验证码功能)
谈谈我写作生涯的画图技巧
Get to know linkerd project for the first time
Discussion on error messages and API versions of SAP ui5 getsaplogonlanguage is not a function
Detailed explanation of navigation component of openharmony application development
2021-12-22 transaction record
Distance measuring sensor chip 4530a used in home intelligent lighting
深度长文探讨Join运算的简化和提速
随机推荐
Simply take stock reading notes (4/8)
深度长文探讨Join运算的简化和提速
SAP UI5 视图里的 OverflowToolbar 控件
由扫地增而引起的小叙
946. Verify stack sequence
Compile kernel modules separately
Transactions from December 29, 2021 to January 4, 2022
关于 SAP UI5 floating footer 显示与否的单步调试以及使用 SAP UI5 的收益
Get to know linkerd project for the first time
HiEngine:可媲美本地的云原生内存数据库引擎
Super efficient! The secret of swagger Yapi
百日完成国产数据库opengausss的开源任务--openGuass极简版3.0.0安装教程
946. 验证栈序列
What if wechat is mistakenly sealed? Explain the underlying logic of wechat seal in detail
Compilation principle reading notes (1/12)
RHCSA1
Insmod prompt invalid module format
Concurrent performance test of SAP Spartacus with JMeter
NLP engineer learning summary and index
Four common problems of e-commerce sellers' refund and cash return, with solutions