本文由EarlGrey@编程派编译,转载请务必注明作者及出处。 点击“阅读原文”查看答案即可。
引言
想找一份Python开发工作吗?那你很可能得证明自己知道如何使用Python。下面这些问题涉及了与Python相关的许多技能,问题的关注点主要是语言本身,不是某个特定的包或模块。每一个问题都可以扩充为一个教程,如果可能的话。某些问题甚至会涉及多个领域。
我之前还没有出过和这些题目一样难的面试题,如果你能轻松地回答出来的话,赶紧去找份工作吧!
问题1
到底什么是Python?你可以在回答中与其他技术进行对比(也鼓励这样做)。
问题2
补充缺失的代码
def print_directory_contents(sPath):
"""
这个函数接受文件夹的名称作为输入参数,
返回该文件夹中文件的路径,
以及其包含文件夹中文件的路径。
"""
# 补充代码
问题3
阅读下面的代码,写出A0,A1至An的最终值。
A0 = dict(zip(('a','b','c','d','e'),(1,2,3,4,5)))
A1 = range(10)
A2 = [i for i in A1 if i in A0]
A3 = [A0[s] for s in A0]
A4 = [i for i in A1 if i in A3]
A5 = {i:i*i for i in A1}
A6 = [[i,i*i] for i in A1]
问题4
Python和多线程(multi-threading)。这是个好主意码?列举一些让Python代码以并行方式运行的方法。
问题5
你如何管理不同版本的代码?
问题6
下面代码会输出什么:
def f(x,l=[]):
for i in range(x):
l.append(i*i)
print lf(2)f(3,[3,2,1])f(3)
问题7
“猴子补丁”(monkey patching)指的是什么?这种做法好吗?
问题8
这两个参数是什么意思:args,*kwargs?我们为什么要使用它们?
问题9
这些是什么意思:@classmethod, @staticmethod, @property?
问题10
阅读下面的代码,它的输出结果是什么?
class A(object):
def go(self):
print "go A go!"
def stop(self):
print "stop A stop!"
def pause(self):
raise Exception("Not Implemented")class B(A):
def go(self):
super(B, self).go()
print "go B go!"class C(A):
def go(self):
super(C, self).go()
print "go C go!"
def stop(self):
super(C, self).stop()
print "stop C stop!"class D(B,C):
def go(self):
super(D, self).go()
print "go D go!"
def stop(self):
super(D, self).stop()
print "stop D stop!"
def pause(self):
print "wait D wait!"class E(B,C): pass
a = A()
b = B()
c = C()
d = D()
e = E()
# 说明下列代码的输出结果
a.go()
b.go()
c.go()
d.go()
e.go()
a.stop()
b.stop()
c.stop()
d.stop()
e.stop()
a.pause()
b.pause()
c.pause()
d.pause()
e.pause()
问题11
阅读下面的代码,它的输出结果是什么?
class Node(object):
声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系
[邮箱地址] 删除
|