PCEP Practice Question: Functions, Tuples, Dictionaries and Exceptions
A developer is using a lambda function that takes two arguments and returns their sum. Which of the following lambda expressions is correct?
⚠ Common exam trap
Python Institute often tests the misconception that lambda requires an explicit `return` statement, leading candidates to choose Option C, but in reality the expression after the colon is automatically returned.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
lambda a, b: a + b
Option A correctly defines a lambda function that takes two arguments and returns their sum. Option B is a valid lambda but returns the difference (a - b), not the sum, so it does not meet the requirement. Option C is incorrect because lambda expressions cannot include a `return` statement; the result is implicitly returned. Option D uses `def` to define a named function, not a lambda.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
lambda a, b: a + b
Why this is correct
Correct. The expression 'lambda a, b: a + b' is a valid lambda function that sums two arguments.
- ✗
lambda a, b: a - b
Why it's wrong here
Correct. Although it is a duplicate of Option A, it is still a valid lambda expression, so it is also correct.
- ✗
lambda a, b: return a + b
Why it's wrong here
Incorrect. Lambda functions do not use the `return` keyword; the expression after the colon is automatically returned.
- ✗
def add(a, b): return a + b
Why it's wrong here
Incorrect. This uses a `def` statement to define a named function, not a lambda.
Quick reference
Cloud Service Model Comparison
| Model | You Manage | Provider Manages | Examples |
|---|---|---|---|
| IaaS | OS, runtime, apps, data | Hardware, hypervisor, networking | EC2, Azure VMs, GCP Compute Engine |
| PaaS | Apps and data | OS, runtime, middleware, hardware | Elastic Beanstalk, Azure App Service |
| SaaS | Data and settings only | Everything else | Microsoft 365, Salesforce, Workday |
| FaaS / Serverless | Function code only | Infra, scaling, runtime | Lambda, Azure Functions, Cloud Run |
| CaaS | Containers and apps | Kubernetes, OS, hardware | EKS, AKS, GKE |
Go deeper
Related to this question
About these practice questions
One of 498 original PCEP practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This PCEP practice question is part of Courseiva's free Python Institute certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCEP exam.