📜 ⬆️ ⬇️

Extensive review of Python interviews. Hints and Tips

Hello!


Briefly about yourself. I am a mathematician by education, but a programmer by profession. In the field of development since 2006. Although, since I began to study programming at school, I began to write my first programs and games at school (approximately, since 2003). It so happened that I had to learn and work in several languages. If you do not take into account the university lectures on C, C ++, Basic, Pascal and Fortran, then I really worked with Delphi (more than 6 years), PHP (more than 5 years), Embedded (Atmel + PIC about 2.5 years) and the latest Python + time is a bit of Scala. Of course, without the database, too, can not do.


Who is this article for? For everyone who, like me, wanted (or wants) to find for himself a decent well-paid job with an interesting project, a cool team and all sorts of buns. And also for those who wish to raise their level of knowledge and skill.


How did this article come about? After 3 weeks of interviews, searches, studies, sleepless nights (often scrolled through my head possible turns of events, answer choices, etc.) I received quite a lot of suggestions. The first two had to be rejected because the deadline for a decision was over, and I was waiting for proposals from other offices. As a result, I accepted a specific day for myself to decide and waited for the results of current and completed interviews. To be honest, my choice was rather complicated, since the options between which I chose were generally very attractive. In general, I decided to prioritize the direction of development, not the conditions and the project. Even after the decision was made (and the proposals), others continued to come (but for me it was already unimportant).


Before each interview, I rather thoroughly prepared + read out those places, the answers to questions on which I either did not know, or did not remember, or did not figure it out to the end.


I appreciated the questions that could really show my understanding (or misunderstanding) of some fundamental concepts. Unfortunately, such questions could be counted on the fingers of both hands.


In the end, I decided that it was worth collecting all this experience and sharing it with others.


Of course, these questions do not exhaust the knowledge that every experienced developer should have. It seems to me that some things in practice are very rarely used to constantly ask about them. Moreover, probably I will not be mistaken if I say that 90 +% of questions just googling for 10-30 seconds.


I combined some questions into one - to save time and space.
Also at the end of the article I will give links that seemed to me the most interesting.


Content


General theory
  • The first question in most interviews is "What is SOLID?" Honestly, I never could remember the full decoding of this abbreviation, so I either explained it in my own words or asked the other person to suggest at least English names, and then I can decipher. At first, it seemed to me that the interlocutor would understand and accept such an answer option, but for some reason, in two cases, the guys decided that I did not know the answer to this question (I wouldn’t like to comment further on this (hand)). Personally, I once confused Dependency Injection with Dependency Inversion.


  • The second typical question: "What is REST?" and then after "What is Restfull?" or "What are the main conditions here."
    You can find your answer. Personally, I prefer this option .


  • What is HTTP? What are his methods?


  • Which HTTP methods are idempotent and which ones are not?


  • I liked one question about HTTP, which I have never encountered in practice, so I did not know. Let you have a fairly large list of URL pages (for example, audio or video) that need to be downloaded to disk. But for each of them you need to check whether there is enough space on the computer for these files. How to use HTTP (what methods)?
    The correct answer is the HEAD method (read about it). Personally, I gave an answer, about which the interlocutor did not even hear (or forgot) and a quick search showed that I was also right (as an option). I have indicated that I will use the GET method, but in order not to download the entire file I will indicate the Range parameter with the minimum step. Although this will only work if the server sends a non-zero Accept-Ranges parameter in the response. I am writing this to the fact that this question only shows whether I worked with such a task or not. A second search will give a comprehensive answer.


  • What is the difference between authentication and authorization? To be honest, I immediately asked a rhetorical question: "why did you miss another identification?". By this, I carefully tried to make my interlocutor understand that I was aware of these issues.


  • What is the difference between HTTP and HTTPS?


  • What is CSRF-token?


  • What data formats do you know besides JSON, XML?
    There are too many of them, so I will not be limited to a specific list.


  • What is SOAP?
    Stupid question. I do not like these. Why ask what is used once in never, or is it definitely not on my project?


  • What design patterns do you know?
    Google to help you;)


  • At one of the low-level development interviews, they asked a lot about algorithms.
    In general, it is desirable to at least understand approximately what O-large is when assessing the complexity of algorithms. It is also probably desirable to know the basic algorithms: simple search, binary search, sorting, quick sorting, working with trees (bypassing in width and depth). An acquaintance advised me to read the wonderful book "Grokayem Algorithms. Aditya Bhargava". I did not think that it is possible to explain so complex and simple things so beautifully and simply. Read in one breath (honestly)! I strongly recommend to anyone who, like me, does not consider himself an algorithmist. Just no words!



Python
  • What is PEP8? How do you feel about him?


  • What programming patterns do you know and how can you implement them?


  • What are the options for implementing the Singleton pattern on python?
    I also advise you to understand the shortcomings of the implementation through the decorator (especially for testing). The most elegant and versatile way, of course, is through metaclasses.


  • Decorators.
    I think it will be useful to read and understand:



  • How are public, private, static methods implemented in python?


  • What are Metaclasses?
    I advise you to fully read this or that .


  • They did not ask, but I advise you to read about the fundamental differences between the 2nd and 3rd versions (at least 2.7 and 3.4).


  • What is new ()? And how is it different from init ()? In what sequence are they performed?


  • What programs do you know to check the code style? What are the pros and cons of them?
    Personally, I worked with pylint, pychecker, but I named three main ones: pychecker, pylint, pyflakes, because before that I read about them =) By the way, here’s a new issue that tells in detail about tools for analyzing Python code .


  • How do you test the code? What is mocking?
    Personally, I use tox, unittest, nose, or watch what Travis says. About mock better google.


  • Regarding the tests, I liked the following questions:


    • What if the function under test uses a remote connection to external services, which sometimes sees a timeout error, 404, and the like?
    • What if the function under test takes a long time to perform repetitive operations inside it? For example, inside a loop from 1..1000000, where something is read, written, calculated.
      I advise you to read about patching.

  • What data structures do you know in Python? Which ones are mutable / immutable?
    Personally, I now know that there are quite a lot of them. In addition to the typical (dict, list, set, tuple), be sure to read about frozen_set, default_dict, ordered_dict (for new versions is no longer relevant) and what else will be in the office. dock (yes, start with it).


  • How does the hash table (dictionary) work? What are collisions and how to deal with them?
    I think that for high positions it makes sense to know.


  • Where will the search be faster, and where will the search and why: dict, list, set, tuple?


  • How are the values ​​of arguments passed to a function or method?


  • What is a generator? How is it different from the iterator?
    There are shorter articles, but I liked this one . There are a lot of things that cannot be fully disclosed in short responses to stackoverflow.


  • What is list / dict comprehension?


  • I cannot formulate a specific question, so I advise you to read about introspection (using dir (), dir , hasattr (), getattr ()), name mangling.


  • What is the difference between single (_) and double (__) underscores?
    The comprehensive answer is here .


  • What is GIL? What are his problems?


  • What is MRO? What is the difference between MRO2 and MR3 (diamond problem)?
    Start google and you will understand everything yourself.


  • What is and how does old-style differ from new-style classes?


  • What do you know about threading. Threading vs Multiprocessing?
    I advise you to read and try it yourself - http://effbot.org/zone/thread-synchronization.htm . The article is a little old, but it gives a good understanding.


  • Did you work with asyncio? What is its feature?
    I recommend reading the articles about asynchronous Python and feeling it yourself.


  • What is garbage collector (gc)? What are its pros and cons?
    I think everything that is needed for an answer is described here .


  • Why do you need Celery?


  • What is async / await, what are they for and how to use them?


  • There is a function:


    def f(sum, l=[]): l.append(sum) print(l) 

    What will be displayed on the screen:


     l = [1] f(10) // [10] f(10) // [10, 10] f(10, l) // [1, 10] f(10) // [10, 10, 10] print(l) // [1, 10] 


Django / Flask
  • How does Serializer work in django?
  • What is Meta responsible for in the serializer?
  • What is the difference in speed between django and flask (and why)?
  • What is the purpose of these frameworks?
  • How does the authentication system work in django?
  • How is django handled (and generated) by CSRF-token?

Frontend
  • What are cookies? Why are they, how to work with them and where are they stored?
  • Can the server change (add, delete) cookies?
  • What is JWT (JSON Web Token)?

SDLC
  • Agile \ scrum: all you need to know
  • What is the difference between CI and CD? For those who are in the tank: CI - continuous integration, CD - continuous delivery
  • What is the difference between Scrum and Kanban?
  • What types of tests do you know?
    Go aside: unit tests, integration tests, acceptance tests, etc.
  • Question for team leads (most likely): What will you do if there are no tests on the project and the customer does not want to spend time and money on their development?
    Personally, I appeal to customer profitability.
  • What is the Code Debt and how to be with it (live, love, fight)?

Git, Versioning, Refactoring
  • What version control systems do you know (use)?
  • What is Git Flow?
    I advise you just to read , because it is a documented thing.
  • What is Git Rebase?
  • What is Git Cherry pick?
  • What tools do you use for code review?
    Personally, I am a lover of gitkhabovsky web client (it is full of interesting and convenient buns). But my interlocutor decided that I was a burdock and set me a "minus". At home, I googled and saw that there was a lot of specialized software that was too similar to what I had used for more than 3 years. Software as software - an amateur.
    P.S. I didn’t like this moment, because the code review experience is quite large + I had to constantly read commits from 500 to 3000 changes in length (yes, on one of my major projects such committees were the norm), and people decided that since I do not know other utilities - it means burdock.
  • What is push push?
  • What is a precommit check?
  • What is code cohesion & code coupling?

Database

To my surprise, the questions on this topic seemed to me too simple (just like for school), except for literally 2-3.


  • What is a transaction? What are its properties?
  • What are transaction isolation levels? What are they like?
    I advise you to read this carefully, because these are fundamental things .
  • What are nested transactions?
  • What is a cursor and why is it needed?
  • What is the difference between PostgreSQL and MySQL?
  • What is VACUUM in PostgreSQL?
  • What is EXPLAIN? What is the difference between it and EXPLAIN ANALYZE?

Big data

Unfortunately, I remembered a few questions, because my previous experience in developing software and working with databases was important for my interlocutor (this, I think, is very clever).


  • What is Hadoop? ... and HDFS?
  • What is MapReduce and how does it work?
  • Can I create a lot of mappers and reducers (or indicate their number)?
  • What is the difference between Hive and HBase
  • Is it possible to create an index in HBase?
  • What is repartition?
  • What is the difference between repartition and coalesce?
    Very simple and affordable described here .
  • What is a Zookeeper master election?

Challenges

Surprisingly, only in one of a dozen interviews I was asked to write code. Probably because everyone else wanted to check the code after the theoretical part. And since the interviews lasted at least an hour (the longest is three hours!), And all the questions were not asked, the guys just physically had no time to check the code.
In addition to practice, I will not advise anything else.


  1. There is a file containing words separated by a space. For example: "abba com mother bill mother com abba dog abba mother com". You need to find and display the top three words that are most often found together (the order does not matter). That is, in my example of a triple of words, this is "abba com mother", "com mother bill", "mother bill mother", etc. Here the correct answer should be "abba com mother" (frequency - 3 times).
  2. Write a function to bypass the tree in depth (in width).
    So that you do not waste time - I will provide a link where both functions are very nicely and simply implemented.
    There was another simple task: write a generator.

Questions and links from me

For educational purposes, the following articles are worth reading:


  • "Questions for a python interview." I read different ones, but for some reason only these two added to the bookmarks - 1 and 2 . But I advise you google more.
  • Educational program for typing in programming languages .
  • It is a pity that when discussing the database there were no questions on the CAP-theorem. You can learn more here , in more detail .
  • I do not know why the topic about microservices was not touched. I can only assume that those who interviewed me did little to work with them or paid them due attention. However, if you are interested, here is a good little article .
  • Also to my surprise, no one even asked questions about virtualization, docker, containers, Kubernetes. I advise you to at least deal with the docker, the benefit now is the mass of simple step-by-step instructions with explanations.
  • Super useful links on Python .
  • Zen Python in the examples .
  • Anyone who works with a python think it is worth knowing about cool innovations .
  • Few of the interlocutors knew about the dictionaries in the python that the co-author himself tells here .
  • No one asked about Lambda in python, but it’s better to understand what it is and what it is eaten with.
  • Types and tricks in python. The article is old, but most of the "tricks" are still relevant.
  • By the way, for python lovers - a digest of the latest news and other materials .
  • On the front I advise you to see a brief lecture about the cycle of events in JavaScript. I don’t think you know how it really works. Highly recommend .
  • Regarding the server side, it is desirable to understand the difference between nginx and apache. The Internet is full of articles. If it's really interesting, what's the difference under the hood - here is an article with examples .

Advice to anyone who really wants to achieve mastery - do not be lazy to repeat the code in the console (whether it is a python, a database or other things). DO NOT copy, namely repeat. Of course, it means a new material, not one that you have been blindly writing for a long time.


In fact, there were 3-4 times more questions. Something is forgotten. But I did bring the most important ones.


You probably noticed that there were practically no questions on the front. This is because we either did not have time to get to them, or there were so few of them that I forgot them.


By the way, here is a good matrix of competencies in various areas in IT. If you get the opportunity to conduct an interview, I advise you to at least understand what you need to ask and what level, and not to row everyone under the same bar (as is often the case now), too many different areas have accumulated. Personally, I don’t understand why to require a senior front-end to have a good understanding of the database, or a senior back-end to have a deep understanding of the browser engine, or the interaction of the Event loop with the renderer of the browser, or the tester - the ability to find the shortest path in a measured way. graph, etc. I hope, looking at this matrix, you understand what I mean.


I sincerely wish success to all who decide to consolidate for themselves and demonstrate to others their knowledge in order to get a good interesting offer!


UPD:
Here you can practice your interviews, if 4to - pramp.com. Thank you non_smile for the link.



Source: https://habr.com/ru/post/439576/