D335 ITSW 3126 Introduction to Programming in
Python
Final Assessment Review (Qns & Ans)
2025
1. Scenario – Asynchronous Processing in AWS Lambda
A developer is designing an AWS Lambda function in Python to
process large batches of I/O-bound data (e.g., reading from an
external API and writing to DynamoDB). Which Python library
would be best suited to implement non‑blocking asynchronous
I/O in this context?
- A. `threading`
- B. `multiprocessing`
- C. `asyncio`
- D. `subprocess`
©2025
, Correct ANS: C. `asyncio`
Rationale: The `asyncio` library provides tools for writing
asynchronous code using coroutines. It is ideal for I/O-bound
operations where tasks (like external API calls) can be awaited
without blocking the execution flow—a critical factor in reducing
latency and cost in AWS Lambda functions.
---
2. Scenario – Enhancing AWS Lambda Functionality with
Decorators
A cloud engineer wants to add logging and error handling to
several AWS Lambda functions without modifying their core
business logic. Which Python feature allows the engineer to wrap
functions, thereby extending their behavior transparently?
- A. Class inheritance
- B. Decorators
- C. List comprehensions
- D. Lambda functions
Correct ANS: B. Decorators
Rationale: Python decorators modify the behavior of functions
or methods without altering their code. This technique is
©2025
, particularly useful in AWS Lambda to add cross-cutting concerns
(such as logging, authentication, or error handling) in a clean and
reusable manner.
---
3. Scenario – Interacting with AWS Using Boto3
A developer needs to list all Amazon S3 buckets
programmatically from a Python script running on AWS. Which
of the following Boto3 service resource calls would correctly
accomplish this?
- A. `s3 = boto3.resource('s3')` then `s3.list_buckets()`
- B. `s3 = boto3.client('s3')` then `s3.list_buckets()`
- C. `s3 = boto3.session()` then `s3.get_buckets()`
- D. `boto3.list('s3')`
Correct ANS: B. `s3 = boto3.client('s3')` then
`s3.list_buckets()`
Rationale: In Boto3, using the client interface (via
`boto3.client('s3')`) is a common and direct way to call AWS API
operations such as `list_buckets()`, making it suitable for
straightforward resource listing tasks.
---
©2025
Python
Final Assessment Review (Qns & Ans)
2025
1. Scenario – Asynchronous Processing in AWS Lambda
A developer is designing an AWS Lambda function in Python to
process large batches of I/O-bound data (e.g., reading from an
external API and writing to DynamoDB). Which Python library
would be best suited to implement non‑blocking asynchronous
I/O in this context?
- A. `threading`
- B. `multiprocessing`
- C. `asyncio`
- D. `subprocess`
©2025
, Correct ANS: C. `asyncio`
Rationale: The `asyncio` library provides tools for writing
asynchronous code using coroutines. It is ideal for I/O-bound
operations where tasks (like external API calls) can be awaited
without blocking the execution flow—a critical factor in reducing
latency and cost in AWS Lambda functions.
---
2. Scenario – Enhancing AWS Lambda Functionality with
Decorators
A cloud engineer wants to add logging and error handling to
several AWS Lambda functions without modifying their core
business logic. Which Python feature allows the engineer to wrap
functions, thereby extending their behavior transparently?
- A. Class inheritance
- B. Decorators
- C. List comprehensions
- D. Lambda functions
Correct ANS: B. Decorators
Rationale: Python decorators modify the behavior of functions
or methods without altering their code. This technique is
©2025
, particularly useful in AWS Lambda to add cross-cutting concerns
(such as logging, authentication, or error handling) in a clean and
reusable manner.
---
3. Scenario – Interacting with AWS Using Boto3
A developer needs to list all Amazon S3 buckets
programmatically from a Python script running on AWS. Which
of the following Boto3 service resource calls would correctly
accomplish this?
- A. `s3 = boto3.resource('s3')` then `s3.list_buckets()`
- B. `s3 = boto3.client('s3')` then `s3.list_buckets()`
- C. `s3 = boto3.session()` then `s3.get_buckets()`
- D. `boto3.list('s3')`
Correct ANS: B. `s3 = boto3.client('s3')` then
`s3.list_buckets()`
Rationale: In Boto3, using the client interface (via
`boto3.client('s3')`) is a common and direct way to call AWS API
operations such as `list_buckets()`, making it suitable for
straightforward resource listing tasks.
---
©2025