Photo of Python interview questions from top tech companies

58 Python interview questions from top tech companies to practice

Hi, I’m Olga! I have years of experience in data science, most recently at eBay and now I work as an industry mentor at Pathrise, helping data scientists land a great role through technical workshops and 1-on-1s. Check out my list of Python interview questions.

Python is one of the most well known programming languages and it is used by many companies and teams. It has become one of the most common languages for data science. So, if you are looking for data roles, it is important to practice the Python interview questions you will be asked.

We have worked with many data scientists and software engineers with data backgrounds on their job search and a lot of our time goes into technical interview preparation, so we created this list of 58 Python interview questions from real tech companies and tips to keep in mind when you go into the interview.

  1. Infosys question – How do you set a global variable in a function?
  2. Google question – How do I share global variables across modules?
  3. Facebook question – What is a class?
  4. Spotify question – How do I avoid blocking in the connect() method of a socket?
  5. Infosys question – How do I generate random numbers in Python?
  6. Netflix question – How do I emulate os.kill() in Windows?
  7. Infosys question – How can I find the methods or attributes of an object?
  8. Accenture question – What is PEP 8?
  9. Dropbox question – What are Python literals?
  10. CA Technologies – What is a zip() function in Python?
  11. Autodesk question – What is Python’s parameter passing mechanism?
  12. Uber question – How do you overload constructors or methods in Python?
  13. Slack question – What is the difference between a remove() function and del statement?
  14. Accenture question – What is a swapcase() function in Python?
  15. Facebook question – Why do we use join() function in Python?
  16. Google question – Give an example of shuffle() method?
  17. Spotify question – What is the use of a break statement?
  18. Netflix question – What is a tuple in Python?
  19. Accenture question – Which are the file related libraries/modules in Python?
  20. Autodesk question – What are the different file processing modes supported by Python?
  21. Facebook question – How do you find bugs or perform static analysis in a Python application?
  22. CA Technologies – When is the Python decorator used?
  23. Uber question – What is the key difference between a list and tuple?
  24. Dropbox question – How does Python handle memory management?
  25. Slack question – How do you remove whitespaces from a string in Python?
  26. Spotify question – What is NumPy and how is it better than a List in Python?
  27. Google question – What are the different ways to create an empty NumPy array in Python?
  28. Facebook question – What are different ways to create an empty array in Python?
  29. Accenture question – What are the ways to write a function using call by reference?
  30. What is the output of print tuple if tuple = (‘abcd’, 786 , 2.23, ‘john’, 70.2)?
  31. Netflix question – What is the output of print tuple[0] if tuple = (‘abcd’, 786 , 2.23, ‘john’, 70.2)?
  32. Autodesk question – How would you convert a string to all lowercase?
  33. Slack question – What are the built-in types available in Python?
  34. Dropbox question – How would you convert a string to a long in Python? What about a string to a float, object, list, and set?
  35. CA Technologies – How would you convert an object to a string in Python? What about an object to a regular expression?
  36. Google question – What are the principal differences between the lambda and def?
  37. Spotify question – Write a reg expression that confirms an email ID using the Python reg expression module ?
  38. Slack question – Is there a switch or case statement in Python?
  39. Autodesk question – What is a built-in function that Python uses to iterate over a number sequence?
  40. Uber question – What are the optional statements that can be used inside a block in Python?
  41. Facebook question – What is the output of L[1:] if L = [1,2,3]?
  42. CA Technologies – How would you get the max valued item of a list? How would you get the min valued item of a list?
  43. Autodesk question – How does the ternary operator work in Python?
  44. Spotify question – What does the keyword do?
  45. Netflix question – What are the different methods to copy an object in Python?
  46. Uber question – What is the purpose of DocStrings in Python?
  47. CA Technologies – Is Python a case sensitive language?
  48. Dropbox question – What programming paradigm does Python support?
  49. Google question – How would you take input from the user in Python?
  50. Spotify question – What is the output of print str * 2 if str = ‘Hello World!’?
  51. Autodesk question – What is the output of print str + “TEST” if str = ‘Hello World!’?
  52. Facebook question – How do you terminate a line of code in Python?
  53. CA Technologies – How is global value mutation used for thread-safety?
  54. Slack question – How would you compare 2 lists? How would you get the length of a list?
  55. Dropbox question – Write a program to read and write the binary data using Python
  56. Netflix question – What is the output of print tuple[1:3] if tuple = ( ‘abcd’, 786 , 2.23, ‘john’, 70.2 )?
  57. Google question – What is the output of print tuple[2:] if tuple = ( ‘abcd’, 786 , 2.23, ‘john’, 70.2 )?
  58. CA Technologies – What is the purpose of // operator?

Don’t forget – there is more to a successful interview than just answering the questions correctly. Interviewers are looking to make sure you understand what you are doing and that you have the soft skills necessary to be an asset in the role. Use these tips to help you as you work through the challenges in your sessions.

Photo of Python interview questions
  • Start with clarifying questions

The question they give you can probably be interpreted in a few different ways, so read it through carefully and then come up with a few clarifying questions to ask before you begin working. Some examples are: “Are repetitions allowed?” or “Do you want to return permutations or combinations?”

  • Be proactive in your interview

While you go through your problem, provide tidbits of knowledge to your interviewer so they understand what you know without having to ask you directly. This creates a more conversational feeling and minimizes the number of potentially awkward silences, especially in moments where you are thinking and not coding.

  • Provide context and reasoning

You should also be giving the interviewer reasons for your decisions, so that can understand what is going through your mind as you work. Walking them through your thought process and choices will help them get a sense of your mindset, which is especially important if you make a mistake, because they will understand where you went wrong.

  • Get guidance through collaboration

Some interviewers really hate the word “hint” but you can ask for, and receive, support in a different way. If you find yourself struggling at a certain point, make a collaborative statement to the interviewer like “my assumptions are X and Y, I’m thinking of doing Z. But I’m struggling with solving [problem].” You can also try asking questions or making comments like,

  • I was wondering if you had any thoughts.
  • Do you think I’m going down the right direction?
  • Do you think my assumptions are incorrect?

With these Python interview questions & tips in your back pocket, you should be more than prepared for your next technical onsite interview. Feel like you need more help? Check out these resources to practice more software engineering interview questions. You can also check out our other interview question lists:

Pathrise is a career accelerator that works with students and professionals 1-on-1 so they can land their dream job in tech. With these tips and guidance, fellows have seen their interview scores double.

If you want to work with any of our mentors 1-on-1 to get help with your software engineer interviews or with any other aspect of the job search, become a Pathrise fellow.

Apply today

Pathrise logo
Alex MacPherson

Hi I'm Alex! Since graduating from UC Berkeley in 2019, I have worked on the growth team for Pathrise helping job seekers hone their skills to land their dream role through curated content on interview prep, resume building and more.

Leave a Reply

Your email address will not be published. Required fields are marked *