DEV Community

Cover image for 101 questions for python developer

101 questions for python developer

1) What is python?
2) When was the first article about python written?
3) What are there data types in python? In what classes are it divided into?
4) What is lambda-function? What is it purpose?
5) What is PEP 8?
6) How to get documentation about object's attributes?
7) What is docstring?
8) What is the difference between types list and tuple?
9) Can list's index be negative?
10) What does keyword pass mean?
11) What is the difference between a multithreading and multiprocessing application?
12) How to look up the methods of the object?
13) What is *args and **kwargs in determining the function?
14) Does python fully support OOP?
15) What are globals() and locals()?
16) What is stored in the dict attribute?
17) How to check the .py file for syntax errors without launching?
18) When is the keyword self used?
19) What is a decorator? How to write your own?
20) What can be the key in the dictionary?
21) What is the difference between packages and modules?
22) How to convert a line containing a binary code (1 and 0) to number?
23) When is the init function used?
24) What is slice?
25) How to check that one tuple contains all the elements of another tuple?
26) Why cannot an empty list be used as a default argument?
27) What are @classmethod, @staticmethod, @property?
28) What is a synchronous code?
29) What is asynchronous code? Give an example.
30) What will be the result of the next expression?

>>> -30 % 10
Enter fullscreen mode Exit fullscreen mode

31) When is id() method used?
32) What is iterator?
33) What is generator? How is it different from the iterator?
34) Why is the keyword yield used?
35) What is the difference between iter and next?
36) What is a context manager?
37) How to make a python script executable in various operating systems?
38) How to make a copy of the object? How to make a deep copy of the object?
39) Describe the work of the garbage collector in python
40) How to use global variables? Is this a good idea?
41) When is the slots attribute used for?
42) What are namespaces exist in python?
43) How is the memory management in python implemented?
44) What are metaclasses and in what cases they should be used?
45) Why do you need a pdb?
46) What will be the result of the next expression?

>>> [0, 1][10:]
Enter fullscreen mode Exit fullscreen mode

47) How to create a class without a keyword class?
48) How to reboot the imported module?
49) Write a decorator that will intercept errors and repeat function N times.
50) What will be the result of the next expression?

>>> len(' '.join(list(map(str, [[0], [1]]))))
Enter fullscreen mode Exit fullscreen mode

51) Python is an easy. Agree?
52) What are the problems in python?
53) When will be the else branch executed in try...except...else?
54) Does python support multiple inheritance?
55) How are dict and set implemented inside? What is the difficulty of accessing the element? How much memory does each structure consume?
56) What is MRO? How it works?
57) How are arguments moved to functions: by value or by link?
58) With what tools can a static code analysis be performed?
59) What will be printed as a result of the next code?

import sys
arr_1 = []
arr_2 = arr_1
print(sys.getrefcount(arr_1))
Enter fullscreen mode Exit fullscreen mode

60) What is GIL? Why does GIL still exist?
61) Describe the compilation process in python.
62) How to distribute the python code?
63) What are descriptors? Is there difference between the descriptor and the decorator?
64) Why whenever python completes the work, all memory is not released?
65) What will be printed as a result of the next code?

class Variable:

   def __init__(self, name, value):
      self._name = name
      self._value = value

   @property
   def value(self):
      print(self._name, 'GET', self._value)
      return self._value

   @value.setter
   def value(self, value):
      print(self._name, 'SET', self._value)
      self._value = value

var_1 = Variable('var_1', 'val_1')
var_2 = Variable('var_2', 'val_2')
var_1.value, var_2.value = var_2.value, var_1.value
Enter fullscreen mode Exit fullscreen mode

66) What is the lines interning? Why is it in python?
67) How to pack binary dependencies?
68) Why is there no optimization of tail recursion in python? How to realize it?
69) What are wheels and eggs? What is the difference?
70) How to access the module written on python from C and backwards?
71) How to speed up the existing python code?
72) What is pycache? What are .pyc files?
73) What is a virtual environment?
74) Is python imperative or declarative language?
75) What is a package manager? What package managers do you know?
76) What are the advantages of numpy arrays in comparison with python (nested) lists?
77) You need to implement a function that should use a static variable. You can't write a code outside the function and you don't have information about external variables (outside your function). How to do it?
78) What will be printed as a result of the next code?

def f_g():
   yield 43
   return 66

print(f_g())
Enter fullscreen mode Exit fullscreen mode

79) How to implement a dictionary from scratch?
80) Write a one-liner that will calculate the number of capital letters in the file.
81) What are .pth files?
82) What functions from collections and itertools do you use?
83) What does the PYTHONOPTIMIZE flag do?
84) What will be printed as a result of the next code?

arr = [[]] * 5
arr_1, arr_2 = arr, arr
for k, arr in enumerate((arr_1, arr_2)):
   arr[0].append(k)
arr = (arr_1, 5, arr_2)
print(arr)
Enter fullscreen mode Exit fullscreen mode

85) What environment variables affecting the behavior of the python interpreter, do you know?
86) What is Cython? What is IronPython? What is PyPy? Why do they still exist?
87) How to turn back the generator?
88) Give an example of using filter and reduce over iterable object.
89) What will be printed as a result of code execution?

>>> print(_)
Enter fullscreen mode Exit fullscreen mode

90) How does the framework differ from the library?
91) Place the functions in order of efficiency, explain the choice.

def f1(arr):
   l1 = sorted(arr)
   l2 = [i for i in l1 if i < .5]
   return [i * i for i in l2]

def f2(arr):
   l1 = [i for i in arr if i < .5]
   l2 = sorted(l1)
   return [i * i for i in l2]

def f3(arr):
   l1 = [i * i for i in arr]
   l2 = sorted(l1)
   return [i for i in l1 if i < (.5 * .5)]
Enter fullscreen mode Exit fullscreen mode

92) There was memory leak in the working application. How will you start debugging?
93) In what situations is NotImplementedError raised?
94) What is wrong with this code? Why is this necessary?

if __debug__:
   assert False, ("error")
Enter fullscreen mode Exit fullscreen mode

95) What are the magic methods (dunder)?
96) Explain why is it possible?

_MangledGlobal__mangled = "^_^"

class MangledGlobal:

   def test(self):
       return __mangled

assert MangledGlobal().test() == "^_^"
Enter fullscreen mode Exit fullscreen mode

97) What is monkey patching? Give an example of use.
98) How to work with transitive dependencies?
99) What will be printed in the browser window?

<html>
   <link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
   <script defer src="https://pyscript.net/alpha/pyscript.js"></script>
   <body>
      <py-script>
         print(__name__)
         print(__file__)
      </py-script>
   </body>
</html>
Enter fullscreen mode Exit fullscreen mode

100) What are the new functions added in python 3.10?
101) Why sometimes python starts so long (in Windows)?

Top comments (0)