1. Which of the following keywords marks the beginning of a function block in Python?
a) function b) define c) def d) Func
2. Which of the following function headers is correct?
a) def calc(a, b = 5): b) def calc(a = 1, b): c) def calc(a = 1, b = 2, c): d) def calc(a, b = 2, c = 3):
3. Which operator is used in Python to import specific items from a module?
a) -> b) * c) from d) .
4. Which of the following files makes a folder a Python package?
a) [Link] b) [Link] c) [Link] d) [Link]
5. Which of the following is a valid function name?
a) My-Function() b) My Function() c) my_function() d) 2function()
6. Functions that do not return any value are also known as void functions. (True / False)
7. Write the output of the following:
a = (5, 8, 12, 5, 3)
print(max(a) - min(a) + [Link](5))
a) 9 b) 10 c) 11 d) 12
8. Identify the invalid Python statement:
a) print("X", 20, sep="#") b) print("X", sep="#", 20) c) print("X"*5) d) print("X", 20, end="#")
9. Which of the following is not a method of the math module?
a) sqrt() b) factorial() c) randint() d) ceil()
10. Assertion (A): The math module provides mathematical functions like sqrt() and pow().
Reason (R): The pow() function in math module is used for string concatenation.
A) Both A and R are True and R is the correct explanation for A.
B) Both A and R are True but R is not the correct explanation for A.
C) A is True and R is False.
D) A is False and R is True.
11. Assertion (A): The return statement is used to send a value back from a function.
Reason (R): return is used to terminate the function immediately and optionally return a value.
A) Both A and R are True and R is the correct explanation for A.
B) Both A and R are True but R is not the correct explanation for A.
C) A is True and R is False.
D) A is False and R is True.
12. (A) Predict the output of the following code:
def Calc(N):
if N % 2 == 0:
return N + 5
else:
return N * 2
def Show(M=3):
for x in range(M):
print(Calc(x), end="@")
print()
Show(4)
Show()
Show(2)
OR
12. (B) Find the errors in the following code, correct them and predict the output:
def Multiply(Num)
result = 1
for i in range(1, Num + 1):
result = result * i
RETURN result
print(Multiply[3])
print(Multiply(4))
13. (A) Differentiate between return statement and print statement in Python.
OR
13. (B) Predict the output:
def modify(x):
if x % 4 == 0:
x += 10
else:
x *= 2
return x
print(modify(8))
print(modify(5))
14. (A) Explain the purpose of the return statement in Python functions with an example.
OR
14. (B) Identify and correct the errors in the following code and show the output:
total = 100
def compute(a, b):
total = a * b
print("Inside Function:", total)
return total
compute(5, 10)
print("Outside Function:", total)
15. (A) Predict the output:
x = 20
def display(sym):
x = 10
print(x, end=sym)
x *= 3
print(x, end=sym)
print(x*2)
display("#")
print(x)
OR
15. (B) What is a module in Python? Explain the steps to create and import a user-defined module.
16. (A) Predict the output:
msg = "PYTHON"
def change(text):
text = "JAVA"
print(text, end='$')
change(msg)
print(msg)
OR
16. (B) Write the output:
x=3
def compute(a, b=2):
global x
x = a**b + x
print(x, end='@')
compute(4, 3)
compute(a=2)
print(x)
17. Name the Python library modules required to invoke the following functions:
i) sqrt() ii) sin() iii) randint() iv) choice() v) ceil()
[Link] is an argument?
[Link] is the lifetime of a variable?
20. What do you mean by Local and global scope?
21. Explain Scope of variables?
[Link] is the output of the following code:
def func(x = 1,y=2):
x=x+y
y+=1
print (x,y)
func(y=2,x=1)
23. Write a function that receives two tuples and creates a third that contains all elements of the first
followed by all elements of the second.
[Link] a program for nth multiple of Fibonacci Series.
25. Why do we use floor(x) function?