Skip to content
TestMacher
Chapter 4 · Class 12 Computer Science

Functions — Important Questions

31 questions With answers CBSE format

SUMMARY: This chapter covers the concept of functions in Python, including their definition, usage, and importance in programming.
KEY TOPICS: function definition, function call, parameters and arguments, return statement, scope of variables, recursion, built-in functions, lambda functions, function overloading, anonymous functions

Q1 1 Mark

The keyword used to define a function in Python is:

Afunction
Bdef
Cfun
Ddefine
Check answerHide answer
Correct answer: Option 2 — def
Q2 1 Mark

Which of the following is a correct way to call a function add with two arguments 3 and 4?

Acall add(3 4)
Badd(3 4)
Cadd 3 4
Dadd[3 4]
Check answerHide answer
Correct answer: Option 2 — add(3 4)
Q3 1 Mark

The number of values returned by a Python function with no return statement is:

A0
B1 (None)
CError
DUndefined
Check answerHide answer
Correct answer: Option 2 — 1 (None)
Q4 1 Mark

Which keyword in Python is used to indicate that a variable is a global variable inside a function?

Aglobal
Bnonlocal
Cextern
Dpublic
Check answerHide answer
Correct answer: Option 1 — global
Q5 1 Mark

A function that calls itself is known as:

AInner function
BRecursive function
CLambda function
DBuilt-in function
Check answerHide answer
Correct answer: Option 2 — Recursive function
Q6 3 Marks

Differentiate between actual parameters and formal parameters in Python functions.

Q7 3 Marks

Differentiate between local variable and global variable.

Q8 3 Marks

What is a default argument? Give one example.

Q9 3 Marks

Explain pass by value and pass by reference in Python with one example.

Q10 3 Marks

Differentiate between user-defined and built-in functions giving one example each.

Q11 6 Marks

Write a Python function that takes a list and returns a tuple containing maximum minimum and average of list elements.

Q12 6 Marks

Write a Python program using a recursive function to compute the factorial of a number.

Q13 6 Marks

Discuss different types of arguments in Python — positional default keyword and variable-length — with examples.

Q14 6 Marks

Explain the scope of variables in Python (local enclosing global built-in) with one example each.

Q15 6 Marks

Write a Python function that accepts a string and returns a dictionary containing the count of each character.

Q16 6 Marks

Differentiate between actual and formal parameters in Python functions in tabular form.

Q17 1 Mark

Assertion (A): Functions promote code reusability.

Reason (R): A function can be called multiple times from different places.

Show explanationHide explanation
Correct answer: Option 1 — Both A and R are true, and R is the correct explanation of A.
Q18 1 Mark

Assertion (A): A function can return multiple values in Python.

Reason (R): The values are returned as a tuple.

Show explanationHide explanation
Correct answer: Option 1 — Both A and R are true, and R is the correct explanation of A.
Q19 1 Mark

Assertion (A): Default arguments must come after non-default arguments.

Reason (R): Otherwise Python raises a SyntaxError.

Show explanationHide explanation
Correct answer: Option 1 — Both A and R are true, and R is the correct explanation of A.
Q20 1 Mark

Assertion (A): Recursive functions need a base case.

Reason (R): Without it the recursion would never stop and cause a stack overflow.

Show explanationHide explanation
Correct answer: Option 1 — Both A and R are true, and R is the correct explanation of A.
Q21 1 Mark

Assertion (A): The global keyword allows modifying a global variable inside a function.

Reason (R): Without it the variable becomes local to the function.

Show explanationHide explanation
Correct answer: Option 1 — Both A and R are true, and R is the correct explanation of A.
Q22 1 Mark

Statement 1: A function definition starts with the def keyword.

Statement 2: The function body is indented.

Show answerHide answer
Correct answer: Option 1 — Both statements are true.
Q23 1 Mark

Statement 1: Lambda functions are anonymous functions.

Statement 2: They are defined using the lambda keyword.

Show answerHide answer
Correct answer: Option 1 — Both statements are true.
Q24 1 Mark

Statement 1: A function can call other functions.

Statement 2: It can also call itself (recursion).

Show answerHide answer
Correct answer: Option 1 — Both statements are true.
Q25 1 Mark

Statement 1: Functions help in modular programming.

Statement 2: Each function does one specific task.

Show answerHide answer
Correct answer: Option 1 — Both statements are true.
Q26 1 Mark

Statement 1: Keyword arguments improve readability.

Statement 2: The argument name is specified explicitly during the function call.

Show answerHide answer
Correct answer: Option 1 — Both statements are true.
Q27 3 Marks
A student is asked to write a Python program that takes two numbers and an operator (+ - * /) and computes the result using user-defined functions. He decides to write a separate function for each arithmetic operation. He then defines a main function that reads input and calls the appropriate function.
  1. Which keyword is used to define a function in Python?
    Afunction
    Bdef
    Cfun
    Ddefine
  2. Which scope does a variable defined inside a function have?
    ALocal
    BGlobal
    CBuilt-in
    DClass
  3. Write a Python program implementing the calculator using one function per operation.
Show answersHide answers
1. Option 2 — def
2. Option 1 — Local
3. The student writes def add(a b): return a+b and similar functions for sub mul div. He then writes def main(): a = float(input()); b = float(input()); op = input(); if op == '+': print(add(a b)) etc. Functions promote modular code reusability and easier testing. Each function does one thing well; the main function orchestrates them.
Q28 6 Marks

For each function call predict its return value.

Call to f(a, b=10)Return value
f(5)?
f(5, 7)?
f(b=4, a=3)?
f(*[2, 3])?
f()?
Q29 5 Marks

For each function call identify if it is recursive or iterative.

FunctionType (recursive/iterative)
factorial via self-call?
factorial via for loop?
fibonacci via self-call?
even() returning n%2==0?
sum_list via self-call?
Q30 3 Marks

Study the table on Python function arguments and answer:

TypeDescriptionExample
PositionalOrder mattersf(1, 2)
KeywordName = valuef(a=1, b=2)
DefaultDefault if absentdef f(a, b=10)
Variable-length*args / **kwargsdef f(*args)
  1. Which type of argument has a default value if not provided?
    APositional
    BKeyword
    CDefault
    DVariable-length
  2. Which is used for variable-length keyword arguments?
    A*args
    B**kwargs
    CBoth
    D
  3. Discuss the four types of arguments in Python with one example each.
Show answersHide answers
1. Option 3 — Default
2. Option 2 — **kwargs
3. Python supports four kinds of arguments. Positional arguments are matched by order. Keyword arguments use name=value syntax for clarity. Default arguments use a default value when the caller omits the argument. Variable-length *args (tuple) and **kwargs (dict) accept any number of additional positional/keyword arguments. The order in def is positional then default then *args then **kwargs.
Q31 3 Marks

Study the function call and return diagram and answer:

Functions figure
  1. The arguments passed to a function during a call are called:
    AActual parameters
    BFormal parameters
    CDefault parameters
    DVariable parameters
  2. A function with no return statement returns:
    A0
    B1
    CNone (None object)
    Dundefined
  3. Differentiate between actual and formal parameters and explain function return mechanism.
Show answersHide answers
1. Option 1 — Actual parameters
2. Option 3 — None (None object)
3. When a function is called actual parameters are passed to formal parameters defined in the function header. The function executes and may return a value using return. Without an explicit return Python returns None. Functions promote modular code reusability and easier testing.

Make a full Computer Science paper on Functions.

Pick the question mix, set the marks, hit generate. You get a ready-to-print paper with an answer key.

Generate your paper — free