Ace Your Next Coding Interview: Top 10 Essential Python Q&As
1. What is the difference between a list and a tuple?
* List is mutable
* Tuple is immutable
2. What is the difference between a list and a dictionary?
* List stores ordered values
* Dictionary stores key value pairs
3. What is a lambda function?
* A small anonymous function
* Used for short operations
4. What is list comprehension?
* A concise way to create lists
* Faster and cleaner than loops
5. What is the difference between == and is?
* == compares values
* is compares memory location
6. What are decorators?
* Functions that modify other functions
* Used for logging, validation, caching
7. What is a generator?
* A function that yields values one by one
* Saves memory
8. What is the difference between deep copy and shallow copy?
* Shallow copy copies references
* Deep copy copies full data
9. What is exception handling?
* Handles errors using try except
* Prevents program crash
10. What is the GIL in Python?
* Global Interpreter Lock
* Allows one thread to execute at a time
No comments:
Post a Comment