Day_8 · 函数:把代码装进"盒子"反复用 #9
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
今日知识点
def 名字(参数):,用return返回结果名字(实参)def greet(name="朋友"):—— 不传就用默认值先学(教程)
任务(后做)
新建
day8.py:is_adult(age),年龄 ≥ 18 返回True否则False,然后用它给三个年龄(15、20、25)分别打印"成年/未成年"。
完成标准
return和print的区别(函数里不 return 会返回什么?)提交方式:把
day8.py代码贴在当日工单评论里。参考解答(先做再看)
https://github.com/wyn-netizen/hello-daily-challenge
喵
嗷
day8完成
1
8
1
1
8
`def add(a,b):
return a+b
print(add(1,2))
print(add(10,20))
def greet(name):
return f"你好,{name}"
print(greet("张三"))
def greet2(name="朋友"):
return f"你好,{name}"
print(greet2())
print(greet2("李四"))`
1
。
Day_8 · 函数(加法、打招呼、默认参数、求平均)