source codehtml
[ZZ]知名互联网公司Python的16道经典面试题及答案 - 浩然119 - 博客园python
百度大牛总结十条Python面试题陷阱,看看你是否会中招 - Python编程c++
Python练手题,敢来挑战吗? - Python编程git
Python面试攻略(coding篇)- Python编程github
2018年最多见的Python面试题&答案(上篇)- Python编程面试
100+Python编程题给你练~(附答案)- AI科技大本营算法
Python 面试问答 Top 25 - 机器学习算法与Python学习编程
春招苦短,我用百道Python面试题备战 - 机器之心app
110道python面试题 - Python爱好者社区机器学习
Python 面试中 8 个必考问题 - 机器学习算法与Python学习
Python 爬虫面试题 170 道:2019 版
函数参数
1 # -*- coding: utf-8 -*- 2 """ 3 @author: hao 4 """ 5 6 def myfun1(x): 7 x.append(1) 8 9 def myfun2(x): 10 x += [2] 11 12 def myfun3(x): 13 x[-1] = 3 14 15 def myfun4(x): 16 x = [4] 17 18 def myfun5(x): 19 x = [5] 20 return x 21 22 # create a list 23 mylist = [0] 24 print(mylist) # [0] 25 26 # change list 27 myfun1(mylist) 28 print(mylist) # [0, 1] 29 30 # change list 31 myfun2(mylist) 32 print(mylist) # [0, 1, 2] 33 34 # change list 35 myfun3(mylist) 36 print(mylist) # [0, 1, 3] 37 38 # did NOT change list 39 myfun4(mylist) 40 print(mylist) # [0, 1, 3] 41 42 # return a new list 43 mylist = myfun5(mylist) 44 print(mylist) # [5] 45 46 47 def myfun(x=[1,2]): 48 x.append(3) 49 return x 50 51 print(myfun()) # [1, 2, 3] 52 53 # result is not [1, 2, 3] coz x was changed 54 print(myfun()) # [1, 2, 3, 3]
Consecutive assignment
1 a = b = 0 2 3 a = 1 4 5 print(a) # 1 6 print(b) # 0 7 8 a = b = [] 9 10 a.append(0) 11 12 print(a) # [0] 13 print(b) # [0] 14 15 a = [] 16 b = [] 17 18 a.append(0) 19 20 print(a) # [0] 21 print(b) # []