Important Question on Functions in Python

Functions in Python – MCQs

🧠 Chapter 3: Working with Functions – MCQs

Question 1: What is the default return value for a function that does not return any value explicitly?

  • A) None
  • B) int
  • C) double
  • D) null
Show Answer
✅ A) None — The default return value is None.

Question 2: Which of the following items are present in the function header?

  • A) function name only
  • B) both function name and parameter list
  • C) parameter list only
  • D) return value
Show Answer
✅ B) both function name and parameter list

Question 3: Which of the following keywords marks the beginning of the function block?

  • A) func
  • B) define
  • C) def
  • D) function
Show Answer
✅ C) def

Question 4: What is the name given to the area of memory where the system stores parameters and local variables of a function call?

  • A) a heap storage area
  • B) a stack
  • C) an array
Show Answer
✅ B) a stack

Question 5: Pick the correct statement to complete the function body:

def f(number):
    # Missing function body
print(f(5))
  • A) return “number”
  • B) print(number)
  • C) print(“number”)
  • D) return number
Show Answer
✅ D) return number

Question 6: Which of the following function headers is correct?

  • A) def f(a = 1, b):
  • B) def f(a = 1, b, c = 2):
  • C) def f(a = 1, b = 1, c = 2):
  • D) def f(a = 1, b = 1, c = 2, d):
Show Answer
✅ C) def f(a = 1, b = 1, c = 2):

Question 7: Which of the following statements is not true for parameter passing to functions?

  • A) You can pass positional arguments in any order.
  • B) You can pass keyword arguments in any order.
  • C) You can call a function with positional and keyword arguments.
  • D) Positional arguments must be before keyword arguments in a function call.
Show Answer
✅ A) You can pass positional arguments in any order.

Question 8: Which of the following is not correct in context of Positional and Default parameters?

  • A) Default parameters must occur to the right of Positional parameters.
  • B) Positional parameters must occur to the right of Default parameters.
  • C) Positional parameters must occur to the left of Default parameters.
  • D) All parameters to the right of a Default parameter must also have Default values.
Show Answer
✅ B) Positional parameters must occur to the right of Default parameters.

Question 9: Which of the following is not correct in context of scope of variables?

  • A) Global keyword is used to change value of a global variable in a local scope.
  • B) Local keyword is used to change value of a local variable in a global scope.
  • C) Global variables can be accessed without using the global keyword in a local scope.
  • D) Local variables cannot be used outside its scope.
Show Answer
✅ B) Local keyword is used to change value of a local variable in a global scope.

Question 10: Which of the following function calls can be used to invoke the below function definition?

def test(a, b, c, d)
  • A) test(1, 2, 3, 4)
  • B) test(a = 1, 2, 3, 4)
  • C) test(a = 1, b = 2, c = 3, 4)
  • D) test(a = 1, b = 2, c = 3, d = 4)
Show Answer
✅ A) and ✅ D) are correct.

Question 11: Which of the following function calls will cause an error while invoking the below function?

def test(a, b, c, d)
  • A) test(1, 2, 3, 4)
  • B) test(a = 1, 2, 3, 4)
  • C) test(a = 1, b = 2, c = 3, 4)
  • D) test(a = 1, b = 2, c = 3, d = 4)
Show Answer
✅ B) and ✅ C) will cause errors.

error: Content is protected !!