Skip to content

Latest commit

 

History

History
102 lines (95 loc) · 9.63 KB

Common Interview Questions (Python).md

File metadata and controls

102 lines (95 loc) · 9.63 KB

Common Interview Questions

  1. REST API design best practices: https://stackoverflow.blog/2020/03/02/best-practices-for-rest-api-design/
  2. Difference between GET, POST, PATCH, PUT and DELETE: https://stackoverflow.com/q/31089221/5353128,
  3. Different types of HTTP status codes: https://restfulapi.net/http-status-codes/
  4. Difference between HTTP and HTTPS: https://www.geeksforgeeks.org/difference-between-http-and-https/
  5. What is API caching? and various API cache eviction techniques (LRU, LFU, FIFO etc.). How to invalidate stale cache? https://youtu.be/U3RkDLtS7uY
  6. Consistent Hashing: https://www.toptal.com/big-data/consistent-hashing
  7. What is generator in Python? https://stackoverflow.com/a/102632/5353128
  8. Difference between generators and iterators in Python? https://stackoverflow.com/q/2776829/5353128
  9. What is hashing? How Python's dict is implemented internally? https://www.geeksforgeeks.org/hashing-data-structure/, https://stackoverflow.com/a/9022835/5353128
  10. How set is implemented internally in Python? https://stackoverflow.com/q/3949310/5353128
  11. What is docker? For what purposes have you used it?
  12. What are python decorators? Write a simple decorator: https://stackoverflow.com/a/1594484/5353128
  13. How to choose between SQL and NoSQL databases for any application? https://github.com/Kaushal28/Design-Patterns/blob/main/SQL%20vs%20NoSQL.md
  14. OOP concepts with real life examples. https://www.geeksforgeeks.org/object-oriented-programming-oops-concept-in-java/
  15. SOLID Principles with examples. https://github.com/Kaushal28/Design-Patterns/blob/main/SOLID%20Principles.md
  16. "is" keyword in Python. https://stackoverflow.com/a/133024/5353128
  17. What are list comprehension in Python? https://stackoverflow.com/a/34835952/5353128
  18. What is the difference between tuple and list in Python? https://stackoverflow.com/q/626759/5353128
  19. Python threads synchronization, concepts of semaphore, mutex, locks, queues etc.: http://www.laurentluce.com/posts/python-threads-synchronization-locks-rlocks-semaphores-conditions-events-and-queues/, https://stackoverflow.com/q/2332765/5353128, https://stackoverflow.com/q/34519/5353128, https://stackoverflow.com/q/16567958/5353128
  20. Python multithreading vs multiprocessing, when to use which concept while using Python?, GIL in cPython: https://stackoverflow.com/a/3046201/5353128, https://stackoverflow.com/q/1294382/5353128
  21. Metaclass in Python: https://stackoverflow.com/q/100003/5353128
  22. Context managers in Python: https://stackoverflow.com/q/3693771/5353128, https://book.pythontips.com/en/latest/context_managers.html#implementing-a-context-manager-as-a-class
  23. What are indexes in relational database?, what are different types of database indexes? https://stackoverflow.com/q/1108/5353128, https://stackoverflow.com/q/36808877/5353128, https://stackoverflow.com/q/20824686/5353128
  24. What is Monkeypatching in Python? Any practical example of using it? https://stackoverflow.com/q/5626193/5353128
  25. Is Python pass by value/by reference? https://stackoverflow.com/q/3949310/5353128
  26. What is virtual environment and when would you use it? https://stackoverflow.com/q/41972261/5353128
  27. What is database sharding? https://docs.mongodb.com/manual/sharding/
  28. What are some API authentication techniques? https://blog.bearer.sh/the-three-most-common-api-authentication-methods/
  29. What API authentication mechanism did you use in your project?
  30. What is CAP theorem? http://ksat.me/a-plain-english-introduction-to-cap-theorem
  31. How would you model your data for MongoDB? Refere all 3 parts: https://www.mongodb.com/blog/post/6-rules-of-thumb-for-mongodb-schema-design-part-1
  32. What is the meaning of REST in REST APIs? https://stackoverflow.com/a/4664013/5353128
  33. What is reverse proxy? https://www.cloudflare.com/en-gb/learning/cdn/glossary/reverse-proxy/
  34. What is the difference between horizontal and vertical scaling? How to achieve them while using MongoDB? https://stackoverflow.com/q/11707879/5353128, https://www.mongodb.com/basics/scaling
  35. What is the difference between microservice and monolithic architectures? When to choose which architecture? https://www.geeksforgeeks.org/monolithic-vs-microservices-architecture/, https://stackoverflow.com/q/46575898/5353128
  36. What are abstract classes and how would you implement one in Python? https://stackoverflow.com/q/13646245/5353128
  37. What are websockets? When are they used? https://www.geeksforgeeks.org/what-is-web-socket-and-how-it-is-different-from-the-http/, https://stackoverflow.blog/2019/12/18/websockets-for-fun-and-profit/
  38. What is the public key cryptography? What are SSL/TLS certificates? https://www.cloudflare.com/en-in/learning/ssl/how-does-public-key-encryption-work/
  39. What are webhooks? When would you use them? Webhooks are callbacks: https://codeburst.io/what-are-webhooks-b04ec2bf9ca2
  40. How would you store graph like data structure in relational/SQL database? For example how would you store and query facebook friends? One possible approach: https://stackoverflow.com/a/46998724/5353128, https://stackoverflow.com/a/20304574/5353128
  41. What happens when you type a URL in your browser and press enter? https://medium.com/@maneesha.wijesinghe1/what-happens-when-you-type-an-url-in-the-browser-and-press-enter-bb0aa2449c1a
  42. How TCP connection is established? How 3 way handshake works in TCP? https://medium.com/@maneesha.wijesinghe1/what-happens-when-you-type-an-url-in-the-browser-and-press-enter-bb0aa2449c1a
  43. What is the difference between TCP, UDP? What is TLS over TCP? https://stackoverflow.com/q/5970383/5353128, For TLS: https://security.stackexchange.com/q/5126/94263
  44. How to scale reads and writes in MongoDB? https://docs.mongodb.com/manual/replication/, https://docs.mongodb.com/manual/sharding/
  45. What is the difference between mongod and mongo? https://stackoverflow.com/a/5490907/5353128
  46. What are linear and non linear data structures? Give a few examples of both: https://www.geeksforgeeks.org/difference-between-linear-and-non-linear-data-structures/
  47. When would you usee array and when would you use linked list? https://stackoverflow.com/q/393556/5353128
  48. What is search time for binary search trees? What impacts the search performance in BSTs? How can you improve it? https://stackoverflow.com/q/526718/5353128
  49. What is general difference between a process and a thread? https://stackoverflow.com/q/200469/5353128
  50. What is a daemon thread? When would you use one in your application? https://stackoverflow.com/q/190010/5353128
  51. What is race condition? How would you prevent it? https://stackoverflow.com/q/34510/5353128
  52. What are different types of semaphores? https://www.guru99.com/semaphore-in-operating-system.html
  53. What is deadlock? https://stackoverflow.com/q/34512/5353128
  54. What is an SQL injection?
  55. What is list comprehension in Python? What are it's advantages over regular for loop? https://stackoverflow.com/a/16341841/5353128
  56. What is ordered dict in Python? https://stackoverflow.com/q/39980323/5353128
  57. What will be the output of the following python code?
for i in range(10):
  i += 1
  print(i)

This will print 1 to 10 because the range of the for loop in python depends on the length of range() function unlike Java or C where the iterator variable determines the length of the loop. Here i will be overwritten every time.

  1. What will be the output of the following python code?
def to_append(ele, to=[])
  to.append(ele)
  return to

print(to_append(12))
print(to_append(42))

This would print [12] and [12, 42] because default values are evaluated at the time of function definition instead of function execution in python. Here are the references: https://stackoverflow.com/q/1132941/5353128, https://web.archive.org/web/20200221224620/http://effbot.org/zone/default-values.htm

  1. What are chained assignments in Python? https://stackoverflow.com/q/7601823/5353128
  2. What is the difference between RUN and CMD in dockerfile? https://stackoverflow.com/a/45137770/5353128
  3. Difference between git pull and git fetch? https://stackoverflow.com/a/292359/5353128
  4. Difference between git merge and git rebase? https://stackoverflow.com/a/16666418/5353128
  5. What is page fault in OS? https://stackoverflow.com/a/6950601/5353128
  6. What objectID in MongoDB consists of? https://stackoverflow.com/questions/7327296/how-do-i-extract-the-created-date-out-of-a-mongo-objectid/7327859
  7. Write a Python class that acts exactly as list but never gives IndexOutOfBounds error (circular list).
class cList(list):
    def __init__(self, lst):
        self.lst = lst
    def __getitem__(self, index):
        return super().__getitem__(index%len(self.lst))
  1. Database joins with examples: https://www.geeksforgeeks.org/sql-join-set-1-inner-left-right-and-full-joins/, https://stackoverflow.com/q/38549/5353128
  2. Types of database indexes: Primary and secondary: https://stackoverflow.com/a/20825201/5353128
  3. Various kind of keys in relational database: https://stackoverflow.com/a/6699670/5353128
  4. Difference between Celery and RabbitMQ? Why we need celery at all? https://stackoverflow.com/q/9077687/5353128
  5. Is multiple inheritance supported by Python? What's the problem with multiple inheritance? https://www.residentmar.io/2019/07/07/python-mixins.html
  6. What is Mixin design pattern in Python? https://www.residentmar.io/2019/07/07/python-mixins.html, Example: https://codereview.stackexchange.com/a/264278/106796
  7. Lambda functions and map, reduce and filter in Python: https://www.geeksforgeeks.org/python-lambda-anonymous-functions-filter-map-reduce/
  8. Linux file system: https://www.linux.com/training-tutorials/linux-filesystem-explained/