变更
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
# 定义函数,并输出信息
|
||||
|
||||
def say_hi():
|
||||
print("hello world")
|
||||
|
||||
|
||||
# say_hi()
|
||||
|
||||
# 演示函数传参
|
||||
# def add(x, y):
|
||||
# result = x + y
|
||||
# print(f"{x}+{y}的结果是{result}")
|
||||
|
||||
|
||||
# add(2,3)
|
||||
|
||||
# 函数返回值
|
||||
# def add(x, y):
|
||||
# result = x + y
|
||||
# return result
|
||||
#
|
||||
#
|
||||
# a = add(32, 33)
|
||||
# print(a)
|
||||
|
||||
# def say_i():
|
||||
# print("i")
|
||||
#
|
||||
#
|
||||
# result = say_i()
|
||||
# print(f"{result}")
|
||||
|
||||
# none 用于if判断
|
||||
# def check_age(age):
|
||||
# if age > 18:
|
||||
# return "SUCCESS"
|
||||
# else:
|
||||
# return None
|
||||
#
|
||||
#
|
||||
# result = check_age(14)
|
||||
# if not result:
|
||||
# print("未成年")
|
||||
|
||||
# 函数说明文档
|
||||
def add(x,y):
|
||||
"""
|
||||
add 函数可以接受两个参数,并实现两参数相加
|
||||
:param x: 参数1
|
||||
:param y: 参数2
|
||||
:return: 返回两数相加的结果
|
||||
"""
|
||||
print(f"{x}+{y}={x+y}")
|
||||
|
||||
Reference in New Issue
Block a user