cs
cs
TIRUTTANI | KANCHIPURAM
---------------------------------------------------------------------------------------------------------------------------
SECTION- A (1 mark)
1. Which of the following Keywords mark the Beginning of the function block?
A) def f(a = 1,b): B) def f(a =1,b,c = 2): C) def f(a = 1,b = 1,c = 2):
a. B G E L b. L E G B c. G E B L d. L B E G
5. Which of the given argument types can be skipped from a function call ?
def greet():
return "Hello"
print(greet())
try:
x = 10 / 2
print("No Error")
except:
print("Error")
22. Explain the purpose of *args in function definitions with a simple example.
OR
What is recursion? Write one condition that must be present in a recursive function.
23.Differentiate between a built-in function and a user-defined function. Give one example of each.
24. Write a try-except block that catches a division by zero error and prints a custom message.
26. Find and write the output of the following python code:
for i in range(N):
if M[i] %5 == 0 :
M[i] //=5
If M[i] %3==0 :
M[i] //=3
ChangeVal (L,4)
for i in L:
Or
28. What will be the output of the following code? Explain your answer.
print(a, b, c)
fun(1, c=4)
SECTION- C (3 x 3 = 9 marks)
29. Write a Python program that asks the user to enter an integer. Handle the case when the user enters
non-numeric data.
30. What is the role of the finally block in exception handling? Write a program that shows its use
when closing a file.
OR
Positional
Keyword
Default
33. Program that receives two numbers in a function and returns the results of all arithmetic
operations (+, -, *, /, %) on these numbers.
34.Explain the use of global key word used in a function with the help of a suitable example.
13. Write a code to demonstrate the use of try, except, else,and finally blocks in Python.
14. Write a program to input two numbers from the user and divide the first by the second. Handle the
following exceptions:
ValueError
ZeroDivisionError