0% found this document useful (0 votes)
13 views5 pages

Python Interview Summary

The document provides a comprehensive set of technical questions and answers related to Python, data structures, web/backend basics, and security. Key topics include Object-Oriented Programming, decorators, exception handling, REST APIs, and security practices. It emphasizes the importance of understanding these concepts for interviews and suggests practicing responses for clarity and confidence.

Uploaded by

nazmus.sami
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views5 pages

Python Interview Summary

The document provides a comprehensive set of technical questions and answers related to Python, data structures, web/backend basics, and security. Key topics include Object-Oriented Programming, decorators, exception handling, REST APIs, and security practices. It emphasizes the importance of understanding these concepts for interviews and suggests practicing responses for clarity and confidence.

Uploaded by

nazmus.sami
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Excellent!

Here’s a set of technical questions and clear, interview-ready conceptual answers


(no code) covering each topic you listed.

⭐ Step 3: Technical Questions & Answers


💡 Python topics
✅ What is OOP, and why do we use classes in Python?

Object-Oriented Programming is a way of organizing code using objects that combine data
(attributes) and behavior (methods). Classes help us model real-world entities, support code
reuse through inheritance, and make code more modular and easier to maintain.

✅ What are magic methods in Python? Can you name a few?

Magic methods are special methods with double underscores that allow us to define how objects
behave with built-in functions and operators. Examples include __init__ (constructor), __str__
(string representation for print), __repr__ (official string representation), and __len__,
__add__.

✅ What is the difference between __str__ and __repr__?

__str__ is meant to return a user-friendly string representation of an object, usually for display
to end users.
__repr__ is meant to return an unambiguous representation of the object, often used for
debugging, and ideally it should look like valid Python code to recreate the object.

✅ What are decorators?

Decorators are a way to modify or extend the behavior of functions or methods without changing
their actual code. They are often used for logging, authentication, or measuring execution time.

✅ What are generators?


Generators are a way to create iterators using functions and the yield keyword. They allow us to
generate values one at a time, which saves memory when working with large data sets.

✅ Why is exception handling important?

Exception handling allows a program to gracefully handle unexpected errors instead of crashing.
We can catch and manage errors, provide fallback behavior, or give meaningful error messages
to the user.

✅ What is the difference between file handling for CSV and JSON?

CSV files store data as plain text in tabular form, mainly for simple structured data. JSON is
used for hierarchical or nested data structures, commonly used in web APIs because it maps
directly to Python dictionaries.

✅ Why do we use unit testing? What are unittest and pytest?

Unit testing helps verify that individual components work as intended, catching bugs early.
unittest is Python’s built-in testing framework, while pytest is a more flexible, user-friendly
framework that supports advanced features like fixtures and parameterized tests.

✅ What is the difference between multithreading and multiprocessing?

Multithreading uses multiple threads within the same process; it is useful for I/O-bound tasks but
limited by Python’s Global Interpreter Lock (GIL).
Multiprocessing runs separate processes with separate memory spaces, useful for CPU-bound
tasks as it can truly run code in parallel.

💡 Data structures & algorithms


✅ When would you use a list, set, or dictionary?
Use a list when you need an ordered collection and duplicates are allowed.
Use a set when you need a collection of unique items and don’t care about order.
Use a dictionary when you need key-value pairs for fast lookups.

✅ What is the time complexity of searching in a list vs a dictionary?

In a list, searching takes O(n) time in the worst case.


In a dictionary, searching by key is on average O(1) due to hashing.

✅ Why is sorting important? Can you name some algorithms?

Sorting helps in organizing data for efficient searching and processing. Common algorithms
include quicksort, mergesort, and bubble sort (though bubble sort is inefficient and mainly used
for learning).

✅ What is string manipulation, and why is it important?

String manipulation refers to tasks like concatenation, slicing, searching, and formatting strings.
It’s important for data processing, user input validation, and preparing output in applications.

✅ What are time and space complexity?

Time complexity measures how the runtime of an algorithm increases with input size.
Space complexity measures how memory usage increases with input size.
Both are important for designing scalable and efficient programs.

💡 Web/backend basics (related to payments)


✅ What is a REST API?

A REST API is a way for systems to communicate over HTTP using stateless requests and
standard methods like GET, POST, PUT, DELETE. It enables different software to interact in a
consistent way.
✅ Why are status codes important in REST APIs?

Status codes let clients know the result of their request. For example, 200 means success, 400
means bad request, 401 means unauthorized, 404 means not found, and 500 means server error.

✅ What is idempotency, and why is it important in payments?

An operation is idempotent if performing it multiple times has the same effect as performing it
once. In payments, this prevents duplicate charges if a request is retried due to network errors.

✅ What is JWT?

JSON Web Token (JWT) is a compact, self-contained way to represent information securely
between parties, often used for authentication and authorization in web applications.

✅ Why is database integration important? What is ORM?

Databases store application data persistently. ORM (Object Relational Mapping) allows
developers to interact with databases using objects instead of writing raw SQL, which makes
code more readable and maintainable.

💡 Security basics
✅ What is hashing, and where is it used?

Hashing transforms data into a fixed-size value, usually for secure storage or verification. It is
commonly used for storing passwords and checking data integrity.

✅ What is encryption?

Encryption transforms data so that only authorized parties can read it. It protects data
confidentiality during storage or transmission.
✅ Why is input validation important?

Input validation prevents harmful data from entering the system, reducing risks like SQL
injection, code injection, or unexpected crashes.

✅ What are secure API practices?

Examples include using HTTPS, validating input, proper authentication and authorization, rate
limiting, and avoiding sensitive data exposure in logs or error messages.

✅ Next Step
• Review and practice saying these answers out loud.
• Keep them short and confident — interviewers prefer clear, to-the-point responses.

✅ If you'd like, I can also prepare example coding problems based on these topics (just
conceptual problems, no solutions), so you can practice explaining your approach. Want me to
do that?

You might also like