
In ECET 2026 Computer Science, Python programming has an important weightage. From functions, parameters, return values, scope – 1 to 2 direct questions are usually asked. Understanding functions is crucial for coding efficiency and exam scoring.
📘 Concept Notes – Python Functions
⚙️ What is a Function?
- A function is a reusable block of code that performs a specific task.
- Functions make programs modular, readable, and reduce repetition.
Syntax:
def function_name(parameters):
# function body
return value
1️⃣ Types of Functions in Python
- Built-in Functions → Example:
print()
,len()
,type()
. - User-defined Functions → Created using
def
. - Lambda Functions → Anonymous, single-line functions using
lambda
.
2️⃣ Function Parameters
Parameters are inputs given to a function.
- Positional Parameters → Values passed in correct order.
def add(a, b):
return a + b
print(add(5, 3)) # Output: 8
- Default Parameters → Have a default value if not passed.
def greet(name="Student"):
print("Hello,", name)
greet() # Output: Hello, Student
greet("Ravi") # Output: Hello, Ravi
- Keyword Parameters → Arguments passed with names.
def student(name, age):
print(name, age)
student(age=20, name="Anu")
- Variable-Length Parameters:
*args
→ Multiple positional arguments.**kwargs
→ Multiple keyword arguments.
def show(*args):
for i in args:
print(i)
show(1, 2, 3) # Output: 1 2 3
3️⃣ Return Statement
- Functions can return values using
return
.
def square(x):
return x * x
print(square(4)) # Output: 16
🔢 Formula Style
(Here only text-based, no boxes, for WordPress QuickLaTeX plugin)
- Function Definition →
- Return Statement →
- Parameter Types →
🔟 10 Most Expected MCQs – ECET 2026
Q1. Which keyword is used to define a function in Python?
A) func
B) define
C) def
D) function
Q2. What will be the output of:
def add(x, y=10):
return x + y
print(add(5))
A) 5
B) 10
C) 15
D) Error
Q3. Which of the following is NOT a built-in function?
A) print()
B) len()
C) sqrt()
D) def()
Q4. Which parameter type allows passing unlimited arguments?
A) *args
B) **kwargs
C) Both A & B
D) None
Q5. The function lambda x: x+5
is an example of:
A) User-defined function
B) Built-in function
C) Lambda function
D) Recursive function
Q6. If a function has no return statement, what does it return?
A) 0
B) NULL
C) None
D) Error
Q7. What is the output of:
def greet(name="ECET"):
return "Hello " + name
print(greet())
A) Hello
B) Hello ECET
C) ECET
D) Error
Q8. Which function gives the length of a list?
A) size()
B) length()
C) len()
D) count()
Q9. Keyword arguments in Python are passed using:
A) Position
B) Name=value
C) Indexing
D) None
Q10. Which statement is correct?
A) Functions cannot return multiple values
B) Functions can return only integers
C) Functions can return multiple values as a tuple
D) None
✅ Answer Key
Q.No | Answer |
---|---|
Q1 | C |
Q2 | C |
Q3 | D |
Q4 | C |
Q5 | C |
Q6 | C |
Q7 | B |
Q8 | C |
Q9 | B |
Q10 | C |
🧠 Explanations of All Answers
- Q1 → C: Functions are defined using
def
. - Q2 → C: Default y=10, so 5+10 = 15.
- Q3 → D:
def
is a keyword, not a function. - Q4 → C:
*args
(positional),**kwargs
(keyword). - Q5 → C:
lambda
defines anonymous functions. - Q6 → C: Python returns
None
if no return. - Q7 → B: Default parameter = “ECET”.
- Q8 → C:
len()
gives length. - Q9 → B: Keyword args use
name=value
. - Q10 → C: Functions can return multiple values as tuples.
🎯 Why Practice Functions for ECET 2026?
- Functions are the foundation of Python coding.
- At least 1 direct MCQ + 1 program-based question is expected.
- Understanding parameter types ensures easy scoring.
- Also useful in real-time coding interviews.
📲 Join Our ECET Prep Community on Telegram
Get daily MCQs, notes, and solved examples!
👉 Join here: @LearnNewThingsHub