zoukankan      html  css  js  c++  java
  • 面试总结之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爱好者社区

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

    Python 爬虫面试题 170 道:2019 版

    用Python手写十大经典排序算法


    函数参数

    • 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
  • 相关阅读:
    第三十七节 log日志模块
    第三十六节 更新备注信息
    第三十五节 取消关注的股票
    第三十四节 路由添加正则功能以及添加关注功能
    第三十三节 通过带有参数的装饰器完成路由功能
    第三十二节 带有参数的装饰器
    Web_CSS
    Web_HTML
    Python操作MySQL
    MySQL_索引原理
  • 原文地址:https://www.cnblogs.com/pegasus923/p/9487170.html
Copyright © 2011-2022 走看看