面试总结之PYTHON

source code

  • https://github.com/haoran119/interview/tree/master/interview%20summary%20of%20python

[ZZ]知名互联网公司Python的16道经典面试题及答案 - 浩然119 - 博客园

  • https://www.cnblogs.com/pegasus923/p/8674215.html

百度大牛总结十条Python面试题陷阱,看看你是否会中招 - Python编程

  • https://mp.weixin.qq.com/s/58KjB7NCbQCMMGZD9CTWFQ
  • https://www.toutiao.com/i6550223737344492039/

Python练手题,敢来挑战吗? - Python编程

  • https://mp.weixin.qq.com/s/y5Ghh0V08oKjCdw68NsLBg
  • https://blog.csdn.net/yang_bingo/article/details/80285205

Python面试攻略(coding篇)- Python编程

  • https://mp.weixin.qq.com/s/bBFt6VMe4PJg_A9rntVCLw
  • https://blog.csdn.net/u013205877/article/details/77542837
  • https://github.com/taizilongxu/interview_python

2018年最常见的Python面试题&答案(上篇)- Python编程

  • https://mp.weixin.qq.com/s/qk62Xkm53QA-3uJ8vTphiA
  • https://juejin.im/post/5b6bc1d16fb9a04f9c43edc3

100+Python编程题给你练~(附答案)- AI科技大本营

  • https://mp.weixin.qq.com/s/2C-njN_WSVhvqIV7L4hycA
  • https://github.com/zhiwehu/Python-programming-exercises/blob/master/100%2B%20Python%20challenging%20programming%20exercises.txt

Python 面试问答 Top 25 - 机器学习算法与Python学习

  • https://mp.weixin.qq.com/s/ICHzi70ygAzKllc-xUKEcg

春招苦短,我用百道Python面试题备战 - 机器之心

  • https://mp.weixin.qq.com/s/qaMiTgRaeDRS59N4DiCYNw
  • https://github.com/kenwoodjw/python_interview_question

110道python面试题 - Python爱好者社区

  • https://mp.weixin.qq.com/s/DlD64oec7P-rNIFoN6DN1g

Python 面试中 8 个必考问题 - 机器学习算法与Python学习

  • https://mp.weixin.qq.com/s/04eZJyvj0TjBnw8_4M9X9A

函数参数

  • Python3 函数 | 菜鸟教程
    • http://www.runoob.com/python3/python3-function.html
    • 在 python 中,strings, tuples, 和 numbers 是不可更改的对象,而 list,dict 等则是可以修改的对象。
      • 不可变类型:变量赋值 a=5 后再赋值 a=10,这里实际是新生成一个 int 值对象 10,再让 a 指向它,而 5 被丢弃,不是改变a的值,相当于新生成了a。
      • 可变类型:变量赋值 la=[1,2,3,4] 后再赋值 la[2]=5 则是将 list la 的第三个元素值更改,本身la没有动,只是其内部的一部分值被修改了。
    • python 函数的参数传递:
      • 不可变类型:类似 c++ 的值传递,如 整数、字符串、元组。如fun(a),传递的只是a的值,没有影响a对象本身。比如在 fun(a)内部修改 a 的值,只是修改另一个复制的对象,不会影响 a 本身。
      • 可变类型:类似 c++ 的引用传递,如 列表,字典。如 fun(la),则是将 la 真正的传过去,修改后fun外部的la也会受影响
    • python 中一切都是对象,严格意义我们不能说值传递还是引用传递,我们应该说传不可变对象和传可变对象。
 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]
View Code

Consecutive assignment

  • Assignment against list is shallow copy.
 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)  # []
View Code

 

转载于:https://www.cnblogs.com/pegasus923/p/9487170.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值