易错题

1.下面这段代码的输出结果是什么,并给出你的解释
def index():
    return [lambda x : i * x for i in range(4)]
print([m(2) for m in index()]) 
2.有一个列表[3,4,1,2,5,6,6,5,4,3,3]请写出一个函数,找出该列表中没有重复的数的总和
3.什么是函数的递归调用?书写递归函数需要注意什么?你能否利用递归函数打印出下面列表中每一个元素(只能打印数字),l = [1,[2,[3,[4,[5,[6,[7,[8,[9]]]]]]]]]
4.你所知道的前端框架和实用插件有哪些,他们各有什么特点
5.使用bootstrap需要注意什么,常用的bootstrap样式有哪些
1.修改后
def func():
    func_list = []
    for i in range(4):
        func_list.append(lambda x,i=i: i * x)
    return func_list
func_list = func()
print(func_list[0](2))
print(func_list[1](2))
print(func_list[2](2))
print(func_list[3](2))
--------------------------------------------------------------------
原题等价于
def func():
    func_list = []
    for i in range(4):
        func_list.append(lambda x: i * x)
    return func_list

func_list = func()
print(func_list[0](2))
print(func_list[1](2))
print(func_list[2](2))
print(func_list[3](2))
-----------------------------------------------------------------------------
2.
解法1:哈希表
l = [3, 4, 1, 2, 5, 6, 6, 5, 4, 3, 3]
dic = {}
for num in l:
    if num not in dic:
        dic[num] = 1
print(sum(dic))
解法2:循环列表
res=0
while l:
    cur = l.pop()
    if cur not in l:
        res +=cur
print(res)
解法3:
print(sum(set(l)))

---------------------------------------------------------------------------------
3.
def my_print(l):
    if not l:
        return
    if len(l) == 1:
        print(l[0])
        return
    elif len(l) ==2:
        print(l[0])
        my_print(l[1])
1.列举你所知道的PEP8 Python编码规范
2.求结果(易错题)
    v1 = 1 or 3
    v2 = 1 and 3
    v3 = 0 and 2 and 1
    v4 = 0 and 2 or 1
    v5 = 0 and 2 or 1 or 4
    v6 = 0 or Flase and 1
3.简述字符编码发展史,以及你所知道的字符编码码,每个字符编码表的在表示数字和字符关系的时候区别
4.简述数据库表设计中一对一、一对多、多对多的应用场景,char与varchar的区别
5.jQ表单筛选器中(:checked)需要注意什么,样式操作都有哪些方法,属性操作方法以及针对checkbox和radio属性操作有何不同
'''
v1 = 1 or 3      -- 1
v2 = 1 and 3      -- 3
v3 = 0 and 2 and 1  -- 0
v4 = 0 and 2 or 1   -- 1
v5 = 0 and 2 or 1 or 4  -- 1
v6 = 0 or Flase and 1   -- False
---------------------------------
v1 = 1 or 3
v2 = 1 and 3
v3 = 0 and 2 and 1
v4 = 0 and 2 or 1
v5 = 0 and 2 or 1 or 4
v6 = 0 or False and 1
>>>1 3 0 1 1 False
'''
记住and是找false。
or是找true。
找到就返回。

1.现有三个普通函数a,b,c都需要用户登陆之后才能访问。现需要你写一个装饰器校验用户是否登陆,并且用户只要登陆一次其他函数在调用时也无需再校验
2.什么是进程,线程,协程,程序中如何依次创建/实现它们
3.js代码书写位置有几种,什么是事件,js如何绑定事件,常见的事件有哪些
4.什么是JQuery,它的基本语法是什么,如何才能顺利的应用jQuery的方法,jQuery查找标签的方式有哪些
posted @ 2020-04-13 15:19  GhostAnt  阅读(121)  评论(0编辑  收藏  举报