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) # []