当前位置:网站首页>第三章 第二节:参数的概念
第三章 第二节:参数的概念
2022-07-21 18:20:00 【中亿丰数字科技有限公司】
Python基础入门(全套保姆级教程)
第三章
第二节:参数的概念
参数:
可以在函数调用的时候. 给函数传递一些信息
个人理解
形参:就是这个规则准备好了,没有目标,只有一个形式。
实参:明确目标,向它出发。
下面是两个例子,自己感悟。。。。
def duiren(ren, lvl): # 形参
print("1. 怒目而视", ren)
print("2. 验证交涉", ren)
if lvl > 99:
print("3. 臭不要脸")
else:
print("3. 你愁啥")
print("4. 怼完手工")
duiren("破键盘", 188) # 在调用函数的时候. 才能知道到底怼谁, 怼道什么程度 -> 实参
duiren("破鼠标", 10)
请用函数编写一个计算器, 能计算 + - * / 四则运算 a + b
def jisuan(a, opt, b):
if opt == "+":
print(a + b)
elif opt == '-':
print(a - b)
elif opt == '*':
print(a * b)
elif opt == '/':
print(a / b)
else:
print("走")
jisuan(999, "+", 666)
jisuan(999, "-", 666)
jisuan(999, "*", 666)
jisuan(999, "/", 666)
jisuan(999, "^&*", 666)
总结:
- 形参, 在函数定义的时候. 需要准备一些变量来接收信息
- 实参, 实际在调用的时候传递的信息
边栏推荐
猜你喜欢
[Datasheet PHY] ksz8081数据手册解读
行业洞察|如何更好地建设数据中台?IT和业务要“齐步走”
Responsive layout - Mobile Web pixels
25.二叉树的中序遍历
Responsive layout viewport and common units
C语言课程设计——宾馆管理系统
EAS 环境结构目录
开发环境 EAS登录 license 许可修改
[original] principle of an automatic nine point calibration tool (including part of the source code)
ConstraintLayout从0到0.n学习
随机推荐
关于线程 thread (3)线程的同步
Detailed explanation of sticky positioning
传统企业的办公模式正在发生着变化,为什么企业需要数字化办公?
Proxy
stm32中的ISP一键下载原理分析
TSP(不要怕)动态规划(我这里很友好)
Wechat applet is not in the following request legal domain name list
EAS 扩展报表常用函数(自用)
开发环境 EAS登录 license 许可修改
EAS extended report data package (from entry to proficiency)
20201127 使用Markdown 画uml图,Graphviz 安装经历吐血整理
Development environment EAS login license modification
Basic definition and concept of graph (II)
Biochemistry review question I · protein
获取当前年月和之前的11个月份
生物化学复习VII·糖代谢
TSP (don't be afraid) dynamic planning (I'm very friendly here)
Responsive layout - font common units
微信小程序 路由介绍
生物化学复习题I·蛋白质