nyk0r

Python interview questions

Jan 18th, 2012
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.49 KB | None | 0 0
  1. Talk to me about the GIL. How does it impact concurrency in Python? What kinds of applications does it impact more than others?
  2. How does Python's garbage collection work?
  3. What is the difference between range and xrange? How has this changed over time?
  4. Here's a function. Optimize it for me.
  5. How do you iterate over a list and pull element indices at the same time?
  6. I'm getting a maximum recursion depth error for a function. What does this mean? How can I mitigate the problem?
  7. How do you enforce ordering for a dictionary-style object?
  8. How does Python's list.sort work at a high level? Is it stable? What's the runtime?
  9. What's the difference between a list, dictionary, and array in Python?
  10. What does this list comprehension do?
  11. Here's a class hierarchy with some methods defined. When I call this function, what gets printed?
  12. What is monkeypatching? How can you do it in Python?
  13. What are some caveats to pickling? Marshaling?
  14. How many ways can you append or concatenate strings? Which of these ways is fastest? Easiest to read?
  15. Print me the full pathname of every file in this directory tree.
  16. What's wrong with this function?
  17. What's your preferred editor? (vim, of course - anything else and they fail.)
  18.  
  19. Basic Python:
  20. =============
  21. - do they know a tuple/list/dict when they see it?
  22. - when to use list vs. tuple vs. dict. vs. set
  23. - can they use list comprehensions (and know when not to
  24. abuse them? :)
  25. - can they use tuple unpacking for assignment?
  26. - string building...do they use "+=" or do they build a list
  27. and use .join() to recombine them efficiently
  28. - truth-value testing questions and observations (do they
  29. write "if x == True" or do they just write "if x")
  30. - basic file-processing (iterating over a file's lines)
  31. - basic understanding of exception handling
  32. Broader Basic Python:
  33. =====================
  34. - questions about the standard library ("do you know if
  35. there's a standard library for doing X?", or "in which
  36. library would you find [common functionality Y]?") Most
  37. of these are related to the more common libraries such as
  38. os/os.path/sys/re/itertools
  39. - questions about iterators/generators
  40. - questions about map/reduce/sum/etc family of functions
  41. - questions about "special" methods (__<foo>__)
  42. More Advanced Python:
  43. =====================
  44. - can they manipulate functions as first-class objects
  45. (Python makes it easy, but do they know how)
  46. - more detailed questions about the std. libraries (such as
  47. datetime/email/csv/zipfile/networking/optparse/unittest)
  48. - questions about testing (unittests/doctests)
  49. - questions about docstrings vs. comments, and the "Why" of
  50. them
  51. - more detailed questions about regular expressions
  52. - questions about mutability
  53. - keyword/list parameters and unpacked kwd args
  54. - questions about popular 3rd-party toolkits (BeautifulSoup,
  55. pyparsing...mostly if they know about them and when to use
  56. them, not so much about implementation details)
  57. - questions about monkey-patching
  58. - questions about PDB
  59. - questions about properties vs. getters/setters
  60. - questions about classmethods
  61. - questions about scope/name-resolution
  62. - use of lambda
  63. Python History:
  64. ===============
  65. - decorators added in which version?
  66. - "batteries included" SQL-capible DB in which version?
  67. - the difference between "class Foo" and "class Foo(object)"
  68. - questions from "import this" about pythonic code
  69. Python Resources:
  70. =================
  71. - what do they know about various Python web frameworks
  72. (knowing a few names is usually good enough, though
  73. knowledge about the frameworks is a nice plus) such as
  74. Django, TurboGears, Zope, etc.
  75. - what do they know about various Python GUI frameworks and
  76. the pros/cons of them (tkinter, wx, pykde, etc)
  77. - where do they go with Python related questions (c.l.p,
  78. google, google-groups, etc)
  79. Other Process-releated things:
  80. ==============================
  81. - do they use revision control
  82. (RCS/CVS/Subversion/Mercurial/Git...anything but VSS) and
  83. know how to use it well
  84. - do they write automated tests for their code
  85. Touchy-feely things:
  86. ====================
  87. - tabs vs. spaces, and their reasoning
  88. - reason for choosing Python
  89. - choice of editor/IDE
  90.  
  91. Do they know a tuple/list/dict when they see it?
  92. When to use list vs. tuple vs. dictionary vs. set?
  93. Can they use list comprehensions (and know when not to abuse them?)
  94. Can they use tuple unpacking for assignment?
  95. String building. Do they use “+=” or do they build a list and use .join() to recombine them efficiently?
  96. Truth-value testing questions and observations (do they write “if x == True” or do they just write “if x”)?
  97. Basic file-processing (iterating over a file’s lines)
  98. Basic understanding of exception handling
  99.  
  100. Questions about the standard library (”do you know if there’s a standard library for doing X?”, or “in which library would you find [common functionality Y]?”) Most of these are related to the more common libraries such as os/os.path/sys/re/itertools
  101. Questions about iterators/generators
  102. Questions about map/reduce/sum/etc family of functions
  103. Questions about “special” methods (__foo__)
  104. Can they manipulate functions as first-class objects (Python makes it easy, but do they know how)
  105. More detailed questions about the std. libraries (such as datetime/email/csv/zipfile/networking/optparse/unittest)
  106. Questions about testing (unittests/doctests)
  107. Questions about docstrings vs. comments, and the “Why” of them
  108. More detailed questions about regular expressions
  109. Questions about mutability
  110. Keyword/list parameters and unpacked keyword arguments
  111. Questions about popular 3rd-party toolkits (BeautifulSoup, pyparsing…mostly if they know about them and when to use them, not so much about implementation details)
  112. Questions about monkey-patching
  113. Questions about PDB
  114. Questions about properties vs. getters/setters
  115. Questions about classmethods
  116. Questions about scope/name-resolution
  117. Use of lambda
  118. Decorators added in which version?
  119. SQL-capable DB in which version?
  120. The difference between “class Foo” and “class Foo(object)”
  121. Questions from “import this” about pythonic code
  122. What do they know about various Python web frameworks (knowing a few names is usually good enough, though knowledge about the frameworks is a nice plus) such as Django, TurboGears, Zope, etc.
  123. What do they know about various Python GUI frameworks and the pros/cons of them (tkinter, wx, pykde, etc)
  124. Where do they go with Python related questions (c.l.p, google, google-groups, etc)
Advertisement
Add Comment
Please, Sign In to add comment