20 Python programming Interview questions you should try to solve

Python is one of the world’s most popular programming languages, it is sleek, object oriented. Before i’ll drop the questions, i want to point out to 10 facts (there are so many) about the Python Programming language.

5 General Facts

  • It was Sir Guido Van Rossum who wrote the Python programming language and released it in 1991.
  • Guido named the language after his favorite comedy opera the “Monty Python’s Flying Circus”.
  • Python is also one of the formally used languages at Google.
  • The BitTorrent software was originally written in Python.
  • It is one of the languages that has an “Else” clause for “For” loops.

5 Technical Facts

  • Python is object oriented. It makes object oriented programming a lot easier to use.
  • Python is reusable. Programmers can save their work in the form of a module which can be used in any other program.
  • Python is portable. It can run on multiple platforms with a similar interface.
  • Python has a rich standard library. It is termed as it’s the biggest strength.
  • Python has a dynamic run-time environment. It prevents segfaults that cause memory access errors.

Ok now to the interview questions..

1. What is the “__init__.py” module used for?

2. What is a negative index in python?
 3. What is pickling and how does it different from unpickling?
 4. What is slicing in python? Explain with example.
 5. What are the different ways to generate random numbers in python?
 6. Why is the “pass” keyword used for in python?
 7. What are iterators in python?
 8. What are generators in python?
 9. How will you run a subprocess or an external program with arguments in python?
 10. How will you remove the duplicate elements from the given list?
 11. How will you print the sum of numbers starting from 1 to 100 (inclusive of both)?
 12. What is the best approach to store a list of an employee’s first and last names?
 13. How would you write a program in python with a function that will output prime numbers from 2–100?
 14. Does python allow arguments pass by value or pass by reference?
 15. What are the different methods python provides for copying an object?
 16. How will you convert a string to a number in python?
 17. How will you set a global variable inside a function?
 18. How will you share global variables across modules?.
 19. Is there a tool to help find bugs or perform the static analysis?
 20. What is the error in this code:

def myfunction:
print(‘Hello World’)

Hope you had a good time trying these questions out?


Tech Beamers
Francis Sunday

Feel free to drop you own Python related questions in the comments below.


Francis Sunday
(@iamfrankcute — #codeHakase)
keep on Hacking.