Programming – Foundations Actual Exam
Complete Questions & Rationales | 100% Verified
| Pass Guaranteed - A+ Graded
Programming Logic & Problem Solving
Q1: When designing an algorithm to solve a problem, what is the primary purpose of
writing pseudocode?
A. To execute the code directly on the computer hardware.
B. To translate the logic directly into machine language binary.
C. To plan the logic and structure of the program without worrying about specific syntax.
[CORRECT]
D. To test the software for runtime errors and memory leaks.
Correct Answer: C
Rationale: The best answer is C because pseudocode is a planning tool used to outline
logic in plain English (or simple notation) before you get bogged down by the strict rules
of a specific programming language.
Q2: Which of the following best describes the concept of "algorithmic thinking" in the
context of programming?
A. Memorizing the syntax of every programming command available.
B. Breaking down a complex problem into a series of step-by-step instructions.
[CORRECT]
C. Writing code without any comments to make it run faster.
D. Using the most complex data structures available regardless of the problem size.
Correct Answer: B
Rationale: Algorithmic thinking is really about problem-solving; it involves taking a big
task, breaking it apart into smaller, manageable steps, and defining a clear sequence to
solve it.
Q3: You are creating a flowchart. Which shape is universally used to represent a
decision point (like a yes/no question)?
A. Parallelogram
B. Rectangle
, C. Diamond [CORRECT]
D. Oval
Correct Answer: C
Rationale: That matches standard flowcharting rules where a diamond shape is used
specifically for conditional branches or decisions, while rectangles are for processes
and ovals are for start/stop points.
Q4: Consider the following logic statement: "If it is raining OR the sprinklers are on, then
the grass will be wet." If the grass is NOT wet, what can you conclude?
A. It is not raining and the sprinklers are not on. [CORRECT]
B. It is not raining, but the sprinklers might be on.
C. It is raining, but the sprinklers are off.
D. It is impossible for the grass to be dry.
Correct Answer: A
Rationale: This runs correctly because of basic logic; for an "OR" condition to be false
(grass not wet), both parts of the condition must be false—meaning neither the rain nor
the sprinklers caused the wetness.
Q5: (Mini-Case Part 1) A developer writes a function intended to calculate the sum of all
integers from 1 up to, but not including, a given number n. The code is as follows:
python
def sum_numbers(n):
total = 0
for i in range(1, n):
total = total + i
return total
If the function is called with sum_numbers(5), what value will be returned?
A. 10 [CORRECT]
B. 15
C. 5
D. 0
Correct Answer: A
Rationale: The best answer is A because the loop runs for i values 1, 2, 3, and 4 (since
range stops before n). Adding those up (1+2+3+4) gives you 10.
Q6: (Mini-Case Part 2) Looking at the same function from the previous question, the
developer actually wants the sum to include the number n. How must the range be
changed to achieve this?
A. Change it to range(n).
B. Change it to range(1, n + 1). [CORRECT]