Programming for Engineers II
Final Exam Review
(Questions & Solutions)
2025
1
, Section I – Multiple Choice (8 Questions)
Question 1:
Which of the following best describes the purpose of using decorators in
Python?
A. To improve runtime performance by compiling functions
B. To dynamically modify or enhance the behavior of functions or
methods without changing their code
C. To optimize memory usage in large-scale computations
D. To enforce strict data type checking at runtime
ANS: B
Rationale: Decorators are used to wrap a function, method, or class,
thereby extending or altering its behavior at runtime without modifying
its source code—a powerful tool for logging, access control, or caching.
---
Question 2:
In the context of scientific computing with Python, which library is most
commonly used for large-scale numerical operations on arrays and
matrices?
A. Matplotlib
B. NumPy
C. Pandas
D. SciPy
ANS: B
Rationale: NumPy provides a powerful N-dimensional array object and
a collection of routines for fast operations on arrays; it serves as the
foundational library for numerical computing and is extensively used in
engineering applications.
2
, ---
Question 3:
When designing an object-oriented program in Python for modeling an
engineering system, which feature allows for the creation of classes that
derive properties and behaviors from a parent class?
A. Encapsulation
B. Inheritance
C. Polymorphism
D. Abstraction
ANS: B
Rationale: Inheritance allows a class (or subclass) to derive attributes
and methods from a parent (base) class, promoting reusability and
hierarchical organization—a key concept in object-oriented design.
---
Question 4:
Which exception is raised in Python when a requested key is not found in
a dictionary?
A. IndexError
B. KeyError
C. NameError
D. ValueError
ANS: B
Rationale: A KeyError is raised when an operation or lookup in a
dictionary fails because the key is not present, allowing proper error
handling in programs that rely on dictionary data structures.
---
Question 5:
In Python’s memory management, what is the primary mechanism used
3