python考试题

  1. 字符串反转 ——> reverse
  2. 公司线上的系统用的什么
  3.  python2和python3的区别
    1. 默认解释器编码   python2用ASCII   python3用Unicode
    2. 输入输出  python2输入:raw_input() input()会把用户输入的显示出来,输出:print 空格或者小括号,python3输入:input()  输出:print()
    3. 整数的除法/int long
    4. Python2中xrange 不会在内存中创建,而是循环中创建,边循环边创建,range在内存中会创建   python3中只有range,代表不会在内存中创建
    5. Py2:文件中必须有__init__py.                           Py3:不需要_init_py.推荐大家以后写代码时,都要加上此文件。
    6. reduce方法
    7. 字典里的keys,values,items都不一样   python2中全是列表 ,不可以通过索引取值,python3全是是迭代器,通过for循环进行取值。
    8. Map/reduce/filter   python2返回一个列表,python3中返回一个迭代器,可以循环但不可以索引
    9. 字符串类型不同,python2中 Unicode  str  python3中 str  bytes
  4.  运算符
  5.  v = 1 or 0 and 0 or 0
  6.  is 和== 的区别?
  7.  is 是比较的对象,==是比较的值
  8.  列举python的数据类型中都有哪些方法
  9. 函数

题1

Info=[]

Def  func():

   print(item)

For item in range(10)

   info.append(func)

Info[0]()

题2

Info=[]

Def  func(i):

   def inner()

      print(i)

   return inner

For item in range(10)

   info.append(func(item))

Info[0]()

Info[1]()

Info[2]()

  1. 函数的参数传递的是什么?

传的是对象的地址

  1. Def func(v1,v2=[])有什么陷阱
  2. Def  func(a,b=[]):

    b.append(a)

    return b

V1 =  func(1)

V2 =  func(2,[11,22])

V3 = func(3)

Print(v1 v2 v3)

[1,3] [11,22,2] [1,3]

  1. 常用的内置模块:json/time   os/sys
  2. 字符串:str  使用Unicode编码用于内存存储     bytes 使用 utf-8编码用于网络传输和硬盘存储。

猜你喜欢

转载自www.cnblogs.com/Ronaldo6688/p/11975359.html