Python Coding and Theory Test
Coding Question:
Write a Python function called `find_common_elements` that takes two lists of integers as input
and returns a list of integers that are common in both lists. Ensure the result does not contain
duplicates, even if there are duplicate common elements in the input lists.
Example:
Input:
list1 = [1, 2, 2, 3, 4]
list2 = [2, 3, 5, 2, 6]
Output: [2, 3]
Theory Questions:
1. Basic Python:
- What is the difference between a list and a tuple in Python?
- What are Python's data types for representing numbers?
2. Functions:
- Explain the difference between `*args` and `**kwargs` in Python functions.
- What is the purpose of the `return` statement in Python?
3. Object-Oriented Programming:
- Define what a class and an object are in Python.
- How does Python achieve encapsulation?
4. Error Handling:
- What is the purpose of the `try-except` block in Python?
- How can you raise an exception in Python?
5. Advanced Topics:
- Explain the difference between shallow copy and deep copy in Python.
- What is the Global Interpreter Lock (GIL) in Python, and why is it significant?
Bonus (Optional): Logical Problem:
Write a Python program to check if a string is a palindrome. A string is a palindrome if it reads
the same backward as forward. Ignore spaces, punctuation, and case sensitivity.