代码拉取完成,页面将自动刷新
# 函数 -> 代码复用
# # 定义一个求和函数
# def calctotal(begin, end):
# total = 0
# for i in range(begin, end + 1):
# total += i
# print(total)
#
# # 调用函数
# calctotal(1, 100)
# calctotal(1, 1000)
# calctotal(1, 10000)
# def fuc1():
# print("hello, world")
#
#
# fuc1()
# def fuc2(a, b):
# return a + b
#
#
# print(fuc2(1.5, True))
# def point():
# x = 10
# y = 20
# return x, y
#
#
# a, b = point()
# print(a, b)
# def point():
# x = 10
# y = 20
# return x, y
#
#
# _, b = point()
# print(b)
x = 10
# def fuc3():
# global x
# x = 20
#
#
# fuc3()
# print(f"x = {x}")
# def fuc4():
# for i in range(1, 11):
# print(i)
#
#
# fuc4()
# cnt = 0
#
#
# def fuc5():
# global cnt
# cnt += 1
# return cnt
#
#
# total = 0
# for i in range(0, 10):
# total += fuc5()
# print(f"total = {total}")
# 递归
# def fuc5(i):
# if i < 2:
# return 1
# return fuc5(i - 1) + fuc5(i - 2)
#
#
# ret = fuc5(3)
# print(f"ret = {ret}")
# 递归求阶乘
# def fuc6(n):
# if n == 1:
# return 1
# return n * fuc6(n - 1)
#
#
# ret = fuc6(5)
# print(f"ret = {ret}")
def fuc7(x, y, flag = False):
if flag:
print(f"x = {x}, y = {y}")
return x + y
ret = fuc7(2, 3, True)
print(f"ret = {ret}")
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。