Top Python Interview Questions for Freshers
1. What are Python's key features?
- Interpreted and high-level
- Dynamically typed
- Easy syntax
- OOP support
- Extensive libraries
- Platform-independent
2. What are Python data types?
- Numeric: int, float, complex
- Sequence: list, tuple, range
- Set: set, frozenset
- Mapping: dict
- Boolean: bool
- Text: str
3. Difference between list and tuple?
List: Mutable, [], slower
Tuple: Immutable, (), faster
4. What is a Python function?
Reusable block of code:
def greet(name):
return f"Hello, {name}"
Top Python Interview Questions for Freshers
5. What is *args and **kwargs?
*args = variable positional args
**kwargs = variable keyword args
6. Difference between is and ==?
== compares values
is compares memory locations
7. What is a lambda function?
Anonymous one-liner function:
square = lambda x: x * x
8. What is list comprehension?
[x*x for x in range(5)]
9. What is a module and package?
Module = Python file
Package = Folder of modules with __init__.py
10. What is pip?
pip installs Python packages:
pip install requests
11. What is exception handling?
try:
Top Python Interview Questions for Freshers
x = 1/0
except:
print('Error')
finally:
print('Done')
12. What is inheritance?
class A: pass
class B(A): pass
13. Python memory management?
Garbage collection, reference counting
14. What are decorators?
Wrap and modify functions using @
15. Python scopes?
LEGB - Local, Enclosing, Global, Built-in
16. Basic SQL Interview Questions
- What is a Primary Key?
- Difference between WHERE and HAVING
- What is JOIN?
- Query to fetch second highest salary:
SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM employees);
Top Python Interview Questions for Freshers
17. Python OOP Concepts
- Class and Object
- Inheritance
- Encapsulation
- Polymorphism
- Abstraction
18. Flask Project Questions
- What is Flask?
- Routing in Flask?
- What is `render_template`?
- How to handle form data in Flask?
- How to connect Flask to a database?