DEPARTMENT OF COMPUTER SCIENCE
End Semester Examination — 2025–26
Time Allowed: 3 Hours Maximum Marks: 45
PYTHON FUNCTION
Subject python function Unit / Chapter unit-4
Total Marks 45 Total Questions 10
Date 18 March 2026 Duration 3 Hours
General Instructions:
1. Answer all questions. Each question carries marks as indicated.
2. Section A — 2-mark questions: Write answers in 2–3 sentences.
3. Section B — 5-mark questions: Write answers in a short paragraph with examples.
4. Section C — 10-mark questions: Write detailed answers with diagrams / programs wherever necessary.
5. Write neatly and legibly. Start each section on a new page.
Section A — 2-Mark Questions Short Answer
1. What is the purpose of the global keyword in a Python function? [2 M]
2. Write a Python function that uses *args to calculate the sum of all input numbers. [2 M]
3. What is the difference between local and global scope of variables in Python? [2 M]
4. Explain the concept of recursive functions in Python with an example. [2 M]
5. How do you import a specific function from a Python module? [2 M]
Section B — 5-Mark Questions Medium Answer
1. Write a Python function that uses **kwargs to print out the key-value pairs of [5 M]
input arguments.
2. Explain the concept of higher-order functions in Python with examples of map(), [5 M]
filter(), and sorted().
3. Create a Python module called 'mymath' with functions to calculate the square and [5 M]
cube of a number, and a constant for pi.
Section C — 10-Mark Questions Essay / Long Answer
1. Write a Python program that uses the random module to generate a random [10 M]
number between 1 and 100, and then uses the [Link] function to select a
random item from a list of colors.
2. Explain the concept of exception handling in Python, including try-except blocks [10 M]
and the different types of exceptions that can occur. Provide an example of how
to handle a specific exception.
*** All the Best *** Total Marks: 45