Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

ECE 203 Programming for Engineers - Final Exam Review (Qns & Ans) - DU 2025, Exams of Programming Languages

ECE 203 Programming for Engineers - Final Exam Review (Qns & Ans) - DU 2025ECE 203 Programming for Engineers - Final Exam Review (Qns & Ans) - DU 2025ECE 203 Programming for Engineers - Final Exam Review (Qns & Ans) - DU 2025ECE 203 Programming for Engineers - Final Exam Review (Qns & Ans) - DU 2025

Typology: Exams

2024/2025

Available from 06/18/2025

clemente-bosco
clemente-bosco 🇺🇸

244 documents

1 / 24

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
ECE 203
Programming for Engineers
Final Exam Review
(Questions & Solutions)
2025
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18

Partial preview of the text

Download ECE 203 Programming for Engineers - Final Exam Review (Qns & Ans) - DU 2025 and more Exams Programming Languages in PDF only on Docsity!

ECE 203

Programming for Engineers

Final Exam Review

(Questions & Solutions)

Section I – Multiple Choice (8 Questions) Question 1: In object‑oriented programming for engineering simulations, which feature best enables modular code reuse and simplifies the management of large software systems? A. Recursion B. Inheritance C. Exception handling D. File I/O operations ANS : B Rationale: Inheritance allows new classes (derived classes) to reuse, extend, or modify the attributes and behaviors of existing classes (base classes). This feature is especially important in designing modular and scalable simulation software for engineering applications.


Question 2: Which Python library is most widely employed for efficient numerical computations and large‑scale array manipulation in engineering applications? A. Matplotlib B. NumPy C. Requests D. Flask ANS : B Rationale: NumPy is the foundational library for numerical computations in Python. Its support for N‑dimensional arrays and vectorized operations makes it indispensable for engineering tasks

Question 5: For solving large sparse linear systems arising in engineering computations, which algorithm is generally preferred? A. Bubble sort B. Conjugate gradient method C. Quick sort D. Depth-first search ANS : B Rationale: The conjugate gradient method is an iterative algorithm particularly effective for solving large sparse systems, which are common in finite element analyses and other engineering simulations.


Question 6: What is the primary advantage of using recursion in algorithm design for solving engineering problems? A. It is always more efficient than iteration. B. It simplifies the code by dividing a problem into smaller, similar sub- problems. C. It requires less memory than iterative loops. D. It avoids the need for error handling. ANS : B Rationale: Recursion breaks complex problems into smaller, similar sub-problems, which often results in simpler, more readable code. However, recursive methods must be used judiciously due to potential performance and memory limitations.


Question 7: In a functional programming approach as applied in engineering modeling, which of the following is a key characteristic? A. Heavy reliance on mutable global variables B. Use of higher-order functions and immutability C. Object sharing through inheritance D. Exclusive use of iterative loops instead of recursion ANS : B Rationale: Functional programming emphasizes immutability and the use of higher-order functions (e.g., map, filter, reduce) to enable concise, side-effect–free code, which is useful when modeling deterministic engineering processes.


Question 8: What is the role of exception handling in programming for reliability in engineering applications? A. To allow the application to crash quickly for debugging purposes B. To capture and gracefully manage run-time errors, ensuring that the system can recover or log errors without halting execution C. To enforce strict data type checking at compile time D. To optimize memory usage during large computations ANS : B Rationale: Exception handling is critical in engineering applications to catch run-time errors and take corrective measures. By gracefully managing errors, the software remains robust and reliable, which is essential in safety‑critical and high‑reliability environments.


Section II – Fill-in-the-Blank (4 Questions)

______ testing is a development process where individual units of code are tested in isolation to ensure that each part functions correctly. ANS : Unit Rationale: Unit testing involves writing tests for the smallest testable parts of an application, ensuring that they behave as expected; it is a fundamental practice for reliable software development in engineering.


Section III – True/False (4 Questions) Question 13: True or False: In Python, decorators provide a mechanism to wrap a function or method to extend its behavior without permanently modifying the original function’s code. ANS : True Rationale: Decorators in Python enable programmers to add functionality to an existing function or method in a flexible and reusable manner, without altering its core implementation.


Question 14: True or False: Recursion in programming is always more efficient in terms of memory usage compared to iterative approaches, making it the preferred choice in engineering applications. ANS : False Rationale: Although recursion can simplify code, it often requires more memory due to function call stack overhead. In many cases, iterative solutions are preferred for their lower memory footprint, especially in performance-critical engineering applications.


Question 15:

True or False: Exception handling improves the robustness of engineering software by preventing program crashes and enabling error logging and graceful recovery. ANS : True Rationale: By catching and handling exceptions, programmers can design systems that recover from errors, log diagnostic information, and operate reliably even under unexpected conditions.


Question 16: True or False: Immutable data structures, as promoted by functional programming paradigms, help reduce side effects and improve code predictability in complex engineering simulations. ANS : True Rationale: Immutable data structures do not change after creation, which minimizes side effects and makes it easier to reason about program behavior—a key benefit in deterministic calculations and simulations.


Section IV – Multiple Response (4 Questions) Question 17: Which of the following are benefits of using high-order functions in engineering programming? (Select all that apply.) A. They promote code reusability through function composition. B. They enhance modularity by abstracting common patterns in data processing. C. They eliminate the need for any error handling in code. D. They facilitate concise expression of complex transformations. E. They inherently boost execution speed beyond that of loops. ANS : A, B, D

version control, peer review, and proper documentation combined with modular design. Relying on informal testing is not sufficient for high- reliability systems.


Question 20: When writing multi-threaded programs in engineering, which factors must be considered to guarantee correct and efficient execution? (Select all that apply.) A. Avoiding race conditions by using proper synchronization techniques B. Ensuring thread safety through careful sharing of immutable data C. Minimizing the number of thread context switches to reduce overhead D. Using global variables extensively for speed E. Designing algorithms that can be decomposed into parallel tasks ANS : A, B, C, E Rationale: Avoiding race conditions, ensuring thread safety, reducing context switch overhead, and creating parallelizable algorithms are essential for efficient multi-threaded programming. The extensive use of global variables is generally discouraged due to potential conflicts. A sinusoidal voltage source, ( v(t) = 10\cos(2\pi \cdot 60t) ) volts, is connected to a series RLC circuit with ( R = 10\ \Omega ), ( L = 0.1\ H ), and ( C = 100\ \mu F ). At the resonant frequency, what is the impedance of the circuit? a) ( 0\ \Omega ) b) ( 10\ \Omega ) c) ( 100\ \Omega ) d) ( \infty\ \Omega ) Correct ANS : b) ( 10\ \Omega )

Rationale: At resonance, the inductive and capacitive reactances cancel each other out. The impedance is then equal to the resistance. Fill-in-the-Blank: In a parallel RLC circuit, the resonant frequency (( f_0 )) is determined by the formula ( f_0 = \frac{1}{2\pi\sqrt{LC}} ). If ( L = 0.2\ H ) and ( C = 50\ \mu F ), the resonant frequency is approximately __ Hz. Correct ANS : 159.15 Hz Rationale: The resonant frequency is calculated using the given formula and the provided values of inductance and capacitance. True/False: The superposition theorem can be applied to circuits containing dependent sources. Correct ANS : True Rationale: The superposition theorem applies to linear circuits, and dependent sources do not violate linearity. Multiple Response: Which of the following are valid methods for analyzing a circuit? (Select all that apply) a) Nodal Analysis b) Mesh Analysis c) Source Transformation d) Phasor Analysis Correct ANS : a), b), c), d) Rationale: All listed methods are standard techniques for circuit analysis.

a) Infinite input impedance b) Zero output impedance c) Infinite open-loop gain d) Zero input bias current Correct ANS : a), b), c), d) Rationale: These are the defining ideal characteristics of an op-amp. Multiple Choice: What is the equivalent capacitance of two capacitors, ( C_1 = 10\ \mu F ) and ( C_2 = 20\ \mu F ), connected in series? a) ( 5\ \mu F ) b) ( 10\ \mu F ) c) ( 15\ \mu F ) d) ( 30\ \mu F ) Correct ANS : a) ( 6.67\ \mu F ) Rationale: The equivalent capacitance for series capacitors is calculated using the formula: ( \frac{1}{C_{eq}} = \frac{1}{C_1} + \frac{1}{C_2} ). Fill-in-the-Blank: The instantaneous power in a circuit is given by the product of instantaneous voltage and __. Correct ANS : current Rationale: This is the fundamental definition of instantaneous power. True/False: The average power in a purely capacitive circuit is zero.

Correct ANS : True Rationale: Capacitors store energy and release it, resulting in no net power dissipation over a cycle. Multiple Response: Which of the following are important considerations when designing a practical filter circuit? (Select all that apply) a) Component tolerances b) Op-amp limitations c) Power supply noise d) Input signal amplitude Correct ANS : a), b), c), d) Rationale: All listed factors influence the performance of a practical filter. Multiple Choice: In a first-order RC circuit, the time constant (( \tau )) is given by: a) ( \tau = RC ) b) ( \tau = \frac{R}{C} ) c) ( \tau = \frac{C}{R} ) d) ( \tau = \frac{1}{RC} ) Correct ANS : a) ( \tau = RC ) Rationale: This is the standard formula for the time constant in an RC circuit. Fill-in-the-Blank: The quality factor (Q) of a series RLC circuit at resonance is a measure of its __.

b) ( 5\ V ) c) ( 10\ V ) d) ( 15\ V ) Correct ANS : c) ( 10\ V ) Rationale: Using Ohm's Law: ( V = IR ). Fill-in-the-Blank: Kirchhoff's Current Law (KCL) states that the sum of currents entering a node is equal to the sum of currents __ the node. Correct ANS : leaving Rationale: KCL is based on the conservation of charge. True/False: The voltage across a capacitor in a DC circuit is constant after the transient response has settled. Correct ANS : True Rationale: After the initial transient, the capacitor acts as an open circuit in a DC circuit. Multiple Response: Which of the following are essential components in a basic operational amplifier circuit? (Select all that apply) a) Input resistor b) Feedback resistor c) Power supply d) Output capacitor Correct ANS : a), b), c)

Rationale: Input and feedback resistors, along with a power supply, are fundamental to op-amp circuit operation. An output capacitor may be used for filtering but is not essential. Multiple Choice (MC) An ideal current source delivers 10 mA to a parallel combination of a 300 Ω and a 600 Ω resistor. What is the voltage across the current source? A) 1 V B) 2 V C) 3 V D) 6 V ANS : B) 2 V Rationale: Equivalent resistance is 200 Ω, so V = I x R = 10 mA x 200 Ω = 2 V. Given a circuit with a 12 V battery, series 4 Ω resistor, and a parallel branch with 8 Ω and 12 Ω, what is the current through the 8 Ω resistor? A) 0.5 A B) 0.6 A C) 1 A D) 2 A ANS : A) 0.5 A Rationale: Find total current, voltage across parallel, then use Ohm’s Law. Thevenin's theorem allows replacement of a linear network by: A) A current source and a single resistor B) A voltage source and a single resistor C) Two resistors in series D) Two resistors in parallel ANS : B Rationale: Thevenin equivalent is a voltage source in series with resistance. In AC steady-state analysis, the impedance of a capacitor is: A) jωC B) - jωC C) 1/(jωC) D) j/(ωC) ANS : C Rationale: Impedance Z_C = 1/(jωC).

A) Load resistance equals source resistance B) Load resistance is much greater C) There is no internal resistance D) Load resistance is half the source resistance ANS : A Rationale: Maximum Power Transfer Theorem. Fill in the Blank In most nodal analysis problems, the reference node is called the _______ node. ANS : ground Rationale: It's the basis for voltage measurements. The Laplace transform of the step input u(t) is _______. ANS : 1/s Rationale: Standard Laplace property. In a DC steady-state, the inductor acts as a _______. ANS : short circuit Rationale: Inductor blocks changes, but passes DC (zero impedance). When converting a voltage source in series with a resistor to a current source, the resistor is placed in _______ with the current source. ANS : parallel Rationale: Source transformation pairs elements in parallel. The quality factor Q of a series RLC circuit is defined as Q = _______ / R. ANS : (ω₀L) Rationale: Q = ω₀L / R. True/False The sum of all currents entering a node is equal to zero in an electric circuit. ANS : True Rationale: By Kirchhoff’s Current Law (KCL). In a purely resistive circuit, the power factor is 0.

ANS : False Rationale: Power factor in a resistive-only circuit is 1. The initial voltage across a capacitor can change instantaneously. ANS : False Rationale: Capacitor voltage cannot change instantly. If a circuit contains only independent sources, superposition cannot be applied. ANS : False Rationale: Superposition is applicable with independent sources. For a reciprocal network, the transfer impedance is the same regardless of input-output reversal. ANS : True Rationale: By definition of network reciprocity. Multiple Response (Select All that Apply)

  1. Which circuit theorems are applicable only to linear circuits? A) Thevenin’s theorem B) Norton's theorem C) Superposition theorem D) Maximum power transfer theorem ANS : A, B, C Rationale: Linear circuit requirement applies; maximum power transfer also applies to some nonlinear conditions.
  2. An inductor in phasor (AC) analysis can be represented as: A) A resistor B) jωL C) 1/(jωL) D) Frequency-dependent impedance ANS : B, D Rationale: Phasor impedance is jωL, and it depends on frequency.
  3. Which of the following are units of conductance?