Undoubtedly, attending a job interview will create stress and some tension, since we are looking to improve our economy, so in these situations, knowledge might fail due to these concerns. In such cases, it is convenient to anticipate to certain issues such as having well-honed technical knowledge as developers.
As has been shown previously, the community around certain programming languages share job search experiences and some common questions that recruiters ask when it is intended to cover a certain vacancy, so this time we will address what the programmers indicate in Python.
The interviewers ask questions that are intended to investigate if the candidate possesses knowledge of the subject, according to specialized pages, among them, they are:
What are Python decorators and how would you use them?
A decorator allows us to make simple modifications to objects that we can call, such as functions, methods or classes, these modifications are made at runtime. A definition of the decorators would be, a function that receives as a parameter another function and returns a function, with what we have:
- The decorator that is a function.
- The function to decorate that is received as a parameter.
- The decorated function that is the function that the decorator returns.
With a decorator we can change the behavior of a function, method or class without modifying its code, that is the advantage of using a decorator. An “envelope” is created around the function to decorate where the code that we want to add is located, this envelope and the original function is a new function that we obtain.
What is the GIL?
It is the mechanism used in CPython to prevent multiple threads from modifying Python objects at the same time in a multi-threaded application. This does not prevent us from having to use synchronization primitives in our applications in Python; the shots do not go around. If in our applications we have several threads accessing a code section with mutable data, we will have a problem if we do not use synchronization primitives.
Explain how to copy in python.
There are two ways in which objects can be copied in python, either superficial or deep. In a surface copy, object B points to the object of a location in memory. Deep in the copy, all things in the object to the memory location are copied to B object from the location of the memory.
What are the rules for local and global variables in Python?
If a variable is defined outside of a function then it is implicitly global. If the variable is assigned to a new value within the function, it means that it is local. If we want it to be global, we have to define it explicitly as universal. The variable referenced within the function is implicit as global.
What is the difference between the list and tuple?
A list can be altered, but not a tuple. A tuple can be used as a key in a dictionary, not a list. A tuple consumes less space than a list.
How is Python interpreted?
Python is an interpreted language, so the Python program runs directly from the source code. It converts the source code that is written by the programmer into an intermediate language, which is translated back into machine language that has to be executed.
These questions may seem simple, but at the time of being in a technical job interview, due to nerves you could waver, so it is worth doing a final review of your knowledge.