会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
蓝绝
博客园
首页
新随笔
联系
订阅
管理
公告
上一页
1
···
15
16
17
18
19
20
21
22
23
24
下一页
2022年9月7日
#
11.2 Bug的常见类型_粗心导致的错误
摘要:
阅读全文
posted @ 2022-09-07 16:01 蓝绝
阅读(36)
评论(0)
推荐(0)
11.1 Bug的由来
摘要:
阅读全文
posted @ 2022-09-07 15:14 蓝绝
阅读(26)
评论(0)
推荐(0)
10.10 斐波那契数列_本章总结
摘要: #斐波那契数列 计算 1,1,2,3,5,8 后面的数为前面两数相加 def fib(n): if n==1: return 1 elif n==2: return 1 else: return fib(n-1)+fib(n-2) #斐波那契数列第6位上的数字 print(fib(6)) print
阅读全文
posted @ 2022-09-07 11:50 蓝绝
阅读(73)
评论(0)
推荐(0)
2022年9月6日
#
10.9 递归函数
摘要: # 递归函数 计算 6!= 6*5*4*3*2*1 def fun(n): if n==1: return n else: res=n*fun(n-1) #递归行数 return res print(fun(6)) E:\PycharmProjects\pythonProject\venv\Scri
阅读全文
posted @ 2022-09-06 21:33 蓝绝
阅读(27)
评论(0)
推荐(0)
10.8 变量的作用域 (局部变量,全局变量)
摘要: # name = '杨老师' #这个为全局变量 def fun(): a=1 #其中的a为局部变量 c=a print(c) return fun() print(name) #其中的name 为全局变量 def fun1(): print(name) #其中的name 为全局变量 return f
阅读全文
posted @ 2022-09-06 21:14 蓝绝
阅读(52)
评论(0)
推荐(0)
10.7 函数的参数总结 * 的使用
摘要: '''列表或元组、字典 转为实参| fun(*lst),fun(**dic) ''' def fun(a,b,c): print('a=',a,'b=',b,'c=',c) fun(10,20,30) #函数调用时的参数传递,称为位置传参 lst=[11,22,33] fun(*lst) # * 函
阅读全文
posted @ 2022-09-06 20:40 蓝绝
阅读(111)
评论(0)
推荐(0)
10.6 函数参数定义_个数可变的位置形参_个数可变的关键字形参
摘要: def fun(*args): #函数定义时,个数可变的位置参数 print(args) fun(10,20,30) #输出结果为元组 def fun1(**args): #函数定义时,个数可变的关键字形参 print(args) fun1(a=10) fun1(a=10,b=20,c=30) #输
阅读全文
posted @ 2022-09-06 14:06 蓝绝
阅读(27)
评论(0)
推荐(0)
10.5 函数参数定义_默认值参数
摘要: def fun(a,b=10): print(a,b) #函数的调用 fun(100) fun(20,30) print('hello',end='\t') #end实际默认值为\n print('world') E:\PycharmProjects\pythonProject\venv\Scrip
阅读全文
posted @ 2022-09-06 12:19 蓝绝
阅读(36)
评论(0)
推荐(0)
10.4 函数的返回值
摘要: print(0) #0的布尔值为False print(bool(8)) #非0的布尔值为True def fun(num): odd=[] even=[] for i in num: if i%2: odd.append(i) else: even.append(i) return odd,eve
阅读全文
posted @ 2022-09-06 11:42 蓝绝
阅读(44)
评论(0)
推荐(0)
10.3 函数参数传递的内存分析
摘要: '''在函数调用过程中,进行参数的传递 如果是不可变对象,在函数体的修改不会影响实参的值 #arg1 的修该为100,不会影响n1的值 如果是可变对象,在函数体的修改会影响到实参的值 #arg2 的修改,append(10),会影响到n2的值 ''' def fun(arg1,arg2): prin
阅读全文
posted @ 2022-09-06 10:55 蓝绝
阅读(26)
评论(0)
推荐(0)
上一页
1
···
15
16
17
18
19
20
21
22
23
24
下一页
博客园
© 2004-2025
浙公网安备 33010602011771号
浙ICP备2021040463号-3