Skip to main content
Home › Blog › #python
Tag

#python

155 articles
What is the difference between multiprocessing threading and asyncio in Python — and how do you choose?

Threading is for I/O-bound tasks with moderate concurrency. Asyncio is for I/O-bound tasks with high concurrency and fine-grained control. Multiprocessing is for CPU-bound tasks requiring true parallelism. The GIL makes…

🏷️
How does pytest work and what makes a good unit test in Python?

pytest discovers and runs test functions automatically providing rich assertion introspection fixtures for dependency injection and parametrize for data-driven tests. A good unit test is fast isolated deterministic and tests…

🏷️
Can you explain the purpose of virtual environments in Python and how you would create one?

Virtual environments in Python are used to create isolated spaces for project dependencies, allowing different projects to have their own packages without conflicts. To create one, you can use the…

🏷️
What specific techniques can you use in Pandas to optimize DataFrame operations for large datasets, and how do they impact performance?

To optimize DataFrame operations in Pandas for large datasets, I would use techniques such as vectorization, avoiding loops, leveraging the ‘numba’ library, and employing efficient data types. These techniques significantly…

🏷️
How do you handle large files in Python without loading them entirely into memory?

Use generators file iteration (files are iterators in Python) or chunk-based reading. Never use read() or readlines() on large files — they load the entire file into memory.

🏷️
How do you handle dependency injection in FastAPI, and why is it beneficial for your application design?

In FastAPI, dependency injection is handled using the Depends function. It allows you to declare dependencies for path operations, enabling cleaner code and better separation of concerns, which enhances testability…

🏷️
How can you efficiently handle missing values in a Pandas DataFrame when preparing data for a machine learning model?

You can handle missing values by using methods like dropna() to remove them or fillna() to impute values. It’s important to choose a strategy based on the data and the…

🏷️
How would you optimize a Scikit-learn model’s performance, specifically in terms of training speed and memory usage?

To optimize a Scikit-learn model’s performance, I would start by using techniques like feature selection to reduce dimensionality, leverage parallel processing with the joblib library, and consider using a more…

🏷️
How would you implement a simple endpoint in FastAPI that returns a list of users from a hardcoded database?

To create a simple endpoint in FastAPI that returns a list of users, you’d define a list of user dictionaries, then create a GET route using the @app.get decorator. This…

🏷️
Can you explain how to define and handle query parameters in a FastAPI endpoint?

In FastAPI, query parameters can be defined by adding function parameters with type annotations in the endpoint function. FastAPI automatically reads them from the query string and validates their types.

🏷️
Can you explain what a list comprehension is in Python and provide an example of when you might use one?

A list comprehension in Python is a concise way to create lists by iterating over an iterable and applying an expression. For example, you can use it to create a…

🏷️
Can you describe a situation where you had to make architectural decisions in a Python application to improve performance and scalability? What factors did you consider?

In a recent project, I had to optimize a Python application that was experiencing significant latency due to synchronous processing. I introduced microservices to decompose the application and implemented asynchronous…

🏷️
1 … 5 6 7 8 9 … 13
2,000 Interview Questions and Answers PDF cover
Developer Interview Kit · PDF

2,000 Interview Questions & Answers, in one PDF

  • Short answers, in-depth explanations, common mistakes and follow-ups
  • 89 topics, from Beginner to Architect, with a clickable contents list
  • 226 extra questions that are not on this website
  • Free Bonus Pack: 30-day study plan, behavioral questions, salary scripts
$7.99 one-time · instant email delivery
260 Developer Learning Paths cover
Also available: 260 Developer Learning Paths $4.99 Week-by-week roadmaps for 16 career tracks (Python, React, Java, DevOps, SQL, AI and more), with a progress tracker on every path. See what's inside →

Get both books for $9.99 (save $2.99):

The material stays free to read online. This is the organised, offline, print-ready PDF edition. Secure payment by PayPal; your personal download link is emailed after payment is confirmed. Digital product, no shipping.