1. General Python Questions
  2. Intermediate Python Concepts
  3. Team and Leadership-Focused Questions

General Python Questions

  1. What is Python?
    • Python is a high-level, interpreted programming language with simple syntax.
  2. Who created Python and when?
    • Guido van Rossum created Python in 1991.
  3. What are Python’s data types?
    • int, float, str, list, tuple, set, dict, bool.
  4. What is a Python interpreter?
    • A program that executes Python code line by line.
  5. What is a module in Python?
    • A file containing Python code that can be reused, usually with a .py extension.
  6. How do you import a module in Python?
    • Use the import statement (e.g., import math).
  7. What is the difference between a list and a tuple?
    • Lists are mutable, while tuples are immutable.
  8. What is the purpose of Python’s dir() function?
    • It lists all attributes and methods of an object.
  9. How do you comment in Python?
    • Use # for single-line comments and triple quotes (""") for multi-line comments.
  10. What are Python’s logical operators?
    • and, or, not.
  11. What is the purpose of the len() function?
    • It returns the length of a collection or string.
  12. What is a Python script?
    • A Python file with .py extension that can be executed.
  13. What is the difference between break and continue?
    • break exits a loop; continue skips the current iteration.
  14. How do you create a dictionary in Python?
    • Using {} with key-value pairs (e.g., {'key': 'value'}).
  15. What is Python’s default encoding?
    • UTF-8.
  16. What is the use of the range() function?
    • It generates a sequence of numbers.
  17. How do you check the Python version?
    • Use python --version or sys.version.
  18. What is Python’s None type?
    • Represents the absence of a value or null value.
  19. What is type() in Python?
    • It returns the type of an object (e.g., type(5) returns <class 'int'>).
  20. What is the output of print(2 ** 3)?
    • 8 (exponentiation).

Intermediate Python Concepts

  1. What is the purpose of Python’s with statement?
    • It simplifies resource management (e.g., file handling).
  2. What is the difference between mutable and immutable types?
    • Mutable types can be modified (list), immutable cannot (tuple, str).
  3. What is a Python lambda function?
    • An anonymous, one-line function defined with lambda.
  4. How do you handle exceptions in Python?
    • Using try, except, else, and finally.
  5. What is a Python set?
    • An unordered collection of unique elements.
  6. What is Python’s *args?
    • Allows passing a variable number of positional arguments to a function.
  7. What is Python’s **kwargs?
    • Allows passing a variable number of keyword arguments to a function.
  8. How does Python handle default arguments in functions?
    • Default values are assigned using the = operator.
  9. What is a Python comprehension?
    • A compact way to generate lists, sets, or dictionaries (e.g., [x**2 for x in range(5)]).
  10. What is slicing in Python?
    • Extracting a portion of a sequence using [start:stop:step].
  11. How do you merge dictionaries in Python?
    • Use dict.update() or {**dict1, **dict2}.
  12. What is Python’s zip() function?
    • Combines multiple iterables into tuples.
  13. How do you create a class in Python?
    • Using the class keyword (e.g., class MyClass:).
  14. What is the purpose of self in Python classes?
    • Refers to the instance of the class.
  15. What is method overriding?
    • Redefining a method in a subclass that exists in the parent class.
  16. How do you open a file in Python?
    • Using open('filename', 'mode').
  17. What is the difference between read() and readlines()?
    • read() reads the entire file, readlines() reads line by line.
  18. What is the enumerate() function?
    • Adds an index to an iterable during iteration.
  19. What is __init__ in Python?
    • A constructor method used to initialize an object.
  20. What are Python’s access modifiers?
    • Public (variable), protected (_variable), private (__variable).

Team and Leadership-Focused Questions

  1. How do you ensure code quality?
    • Use linters, enforce standards, and review code.
  2. How do you prioritize tasks in a Python project?
    • Assess impact and urgency, and align with business goals.
  3. What is your approach to debugging?
    • Use logs, pdb, and debugging tools in IDEs.
  4. How do you conduct a code review?
    • Check for functionality, readability, and adherence to standards.
  5. What tools do you recommend for testing?
    • pytest, unittest, mock.
  6. How do you onboard new team members?
    • Provide documentation, mentoring, and small starter tasks.
  7. How do you ensure deadlines are met?
    • Break tasks into milestones and regularly review progress.
  8. What is your approach to resolving conflicts in a team?
    • Foster communication and ensure focus on shared goals.
  9. How do you decide on a Python library?
    • Assess stability, community support, and documentation.
  10. How do you handle technical debt?
    • Address during regular sprints and maintain documentation.
  11. How do you handle poorly written legacy code?
    • Refactor incrementally and add tests.
  12. What is the role of CI/CD in a Python project?
    • Automates testing and deployment, ensuring reliability.
  13. How do you balance coding and leadership responsibilities?
    • Delegate tasks and allocate focused time for coding.
  14. What metrics do you track in a Python project?
    • Code coverage, performance benchmarks, and bug resolution rates.
  15. How do you mentor juniors in Python?
    • Pair programming, code reviews, and regular feedback.
  16. How do you introduce new technologies?
    • Start with pilot

Quote of the week

“Success is not final, failure is not fatal: It is the courage to continue that counts.”

~ Winston Churchill