面试题

9、[[1,2],[3,4],[5,6]]一行代码展开该列表,得出[1,2,3,4,5,6]
12、python中交换两个数值
5. 请用自己的算法, 按升序合并如下两个list, 并去除重复的元素:

list1 = [2, 3, 8, 4, 9, 5, 6]

list2 = [5, 6, 10, 17, 11, 2]

解答:先转换成集合自动去重,再转换成列表。
6. 请写出打印结果:

x = [0, 1]

i = 0

i, x[i] = 1, 2

print(x)

打印结果: [0, 2], python可以使用连续赋值, 从左至右.
11.
g = lambda x, y=2, z : x + y**z

g(1, z=10) = ?

打印结果: 异常, 形参表末尾才可以有默认参数, z需要提供默认参数.
11.以下的代码的输出将是什么? 说出你的答案并解释。
class Parent(object):
 x = 1
 
class Child1(Parent):
 pass
 
class Child2(Parent):
 pass
 
print (Parent.x, Child1.x, Child2.x)
Child1.x = 2
print (Parent.x, Child1.x, Child2.x)
Parent.x = 3
print (Parent.x, Child1.x, Child2.x)


转载于:https://www.cnblogs.com/aaasssddd/p/10178765.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值