0% found this document useful (0 votes)
17 views2 pages

Python Coding and Theory Assessment

The document contains a Python coding question requiring the creation of a function to find common elements between two lists without duplicates. It also includes a series of theory questions covering basic Python concepts, functions, object-oriented programming, error handling, and advanced topics. Additionally, there is a bonus problem asking for a program to check if a string is a palindrome.

Uploaded by

nikhil18249
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)
17 views2 pages

Python Coding and Theory Assessment

The document contains a Python coding question requiring the creation of a function to find common elements between two lists without duplicates. It also includes a series of theory questions covering basic Python concepts, functions, object-oriented programming, error handling, and advanced topics. Additionally, there is a bonus problem asking for a program to check if a string is a palindrome.

Uploaded by

nikhil18249
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

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.

You might also like