Appearance
Important Questions
1. What is a data type in Python?
- A type tells Python what kind of value is stored.
- It controls which operations are valid.
2. Why are lists and tuples different?
- Lists are changeable.
- Tuples are fixed.
3. What is a higher-order function?
- A function that takes or returns another function.
4. What does lambda do?
- It creates a small anonymous function.
5. Why are comprehensions useful?
- They create new collections clearly and compactly.
6. What is lazy evaluation in Python?
- Python usually is not fully lazy, but generators delay work until values are needed.
7. What is a closure?
- A function that remembers values from the environment where it was created.
8. What is type discipline?
- The rules a language uses to handle types and catch mistakes.
9. Why use type hints?
- They improve readability and help tools detect errors.
10. What is type inference?
- A tool or compiler works out a type from the code.
11. Why use a dataclass?
- It is a simple way to make a data-holding class with less boilerplate.
12. What is a concrete type?
- A fully known, specific type such as
intorStudent.
13. Why do we use recursion?
- It is a natural way to solve problems with smaller versions of the same shape.
14. What is polymorphism in Python?
- One function or method works with many types.
15. How do protocols help?
- They describe shared behavior so different types can be used in the same code.