1 Star 0 Fork 0

哔卟哔卟/Python

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Test8.py 1.31 KB
一键复制 编辑 原始数据 按行查看 历史
哔卟哔卟 提交于 2023-10-04 15:22 . 提交 Python 相关
# 函数 -> 代码复用
# # 定义一个求和函数
# 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}")
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/p_bart/python.git
git@gitee.com:p_bart/python.git
p_bart
python
Python
master

搜索帮助