WGU D278 Scripting and Programming
Foundations Exam 2026/2027 – Verified
Q&As with Detailed Rationales (Test
Bank Bundle - 74 Questions)
*QUESTION 1:*
What is the primary purpose of a variable in programming?
A) To store a value for later use and manipulation
B) To display output to the user
C) To control the flow of execution
D) To repeat a block of code
> 🎯 *CORRECT ANSWER:* A) To store a value for later use and manipulation
> 💡 *CLINICAL RATIONALE:*
> * *Why It's Right:* Variables are fundamental for data storage.
> * *Why Distractors Fail:* Output, flow control, and repetition are separate functions.
> * *Core Takeaway:* Variables hold data.
---
*QUESTION 2:*
Which data type is best suited for storing a person's age?
,A) String
B) Integer
C) Float
D) Boolean
> 🎯 *CORRECT ANSWER:* B) Integer
> 💡 *CLINICAL RATIONALE:*
> * *Why It's Right:* Age is a whole number without decimal points.
> * *Why Distractors Fail:* String is for text; float is for decimals; boolean is true/false.
> * *Core Takeaway:* Use integers for whole numbers.
---
*QUESTION 3:*
What is the correct syntax for declaring a constant in Python?
A) const PI = 3.14159
B) final double PI = 3.14159
C) PI = 3.14159 (by convention, uppercase indicates constant)
D) #define PI 3.14159
> 🎯 *CORRECT ANSWER:* C) PI = 3.14159 (by convention, uppercase indicates constant)
> 💡 *CLINICAL RATIONALE:*
> * *Why It's Right:* Python uses naming conventions rather than explicit constants.
> * *Why Distractors Fail:* The other options are for different languages.
> * *Core Takeaway:* Python constants are a naming convention.
---
*QUESTION 4:*
,A programmer needs to execute a block of code if a condition is true, and another block if it is false.
Which control structure should be used?
A) If-Else
B) For loop
C) While loop
D) Switch statement
> 🎯 *CORRECT ANSWER:* A) If-Else
> 💡 *CLINICAL RATIONALE:*
> * *Why It's Right:* If-else provides a two-way branch based on a condition.
> * *Why Distractors Fail:* Loops are for repetition; switch is for multiple comparisons.
> * *Core Takeaway:* If-else handles true/false branching.
---
*QUESTION 5:*
What will the following Python code output: print("Hello" + " World")
A) Hello World
B) HelloWorld
C) Hello + World
D) Error
> 🎯 *CORRECT ANSWER:* A) Hello World
> 💡 *CLINICAL RATIONALE:*
> * *Why It's Right:* The plus operator concatenates strings with a space.
> * *Why Distractors Fail:* HelloWorld would occur without the space; + is not printed.
> * *Core Takeaway:* String concatenation joins strings.
---
, *QUESTION 6:*
Which operator is used to compare two values for equality in most programming languages?
A) =
B) ==
C) !=
D) <=
> 🎯 *CORRECT ANSWER:* B) ==
> 💡 *CLINICAL RATIONALE:*
> * *Why It's Right:* == is the equality comparison operator.
> * *Why Distractors Fail:* = is assignment; != is inequality; <= is less than or equal.
> * *Core Takeaway:* Use == to test equality.
---
*QUESTION 7:*
What is the result of the expression 5 // 2 in Python?
A) 2
B) 2.5
C) 2.0
D) 3
> 🎯 *CORRECT ANSWER:* A) 2
> 💡 *CLINICAL RATIONALE:*
> * *Why It's Right:* // is floor division, returning the integer quotient.
> * *Why Distractors Fail:* 2.5 is true division; 3 is rounding up.
> * *Core Takeaway:* Floor division discards the remainder.
Foundations Exam 2026/2027 – Verified
Q&As with Detailed Rationales (Test
Bank Bundle - 74 Questions)
*QUESTION 1:*
What is the primary purpose of a variable in programming?
A) To store a value for later use and manipulation
B) To display output to the user
C) To control the flow of execution
D) To repeat a block of code
> 🎯 *CORRECT ANSWER:* A) To store a value for later use and manipulation
> 💡 *CLINICAL RATIONALE:*
> * *Why It's Right:* Variables are fundamental for data storage.
> * *Why Distractors Fail:* Output, flow control, and repetition are separate functions.
> * *Core Takeaway:* Variables hold data.
---
*QUESTION 2:*
Which data type is best suited for storing a person's age?
,A) String
B) Integer
C) Float
D) Boolean
> 🎯 *CORRECT ANSWER:* B) Integer
> 💡 *CLINICAL RATIONALE:*
> * *Why It's Right:* Age is a whole number without decimal points.
> * *Why Distractors Fail:* String is for text; float is for decimals; boolean is true/false.
> * *Core Takeaway:* Use integers for whole numbers.
---
*QUESTION 3:*
What is the correct syntax for declaring a constant in Python?
A) const PI = 3.14159
B) final double PI = 3.14159
C) PI = 3.14159 (by convention, uppercase indicates constant)
D) #define PI 3.14159
> 🎯 *CORRECT ANSWER:* C) PI = 3.14159 (by convention, uppercase indicates constant)
> 💡 *CLINICAL RATIONALE:*
> * *Why It's Right:* Python uses naming conventions rather than explicit constants.
> * *Why Distractors Fail:* The other options are for different languages.
> * *Core Takeaway:* Python constants are a naming convention.
---
*QUESTION 4:*
,A programmer needs to execute a block of code if a condition is true, and another block if it is false.
Which control structure should be used?
A) If-Else
B) For loop
C) While loop
D) Switch statement
> 🎯 *CORRECT ANSWER:* A) If-Else
> 💡 *CLINICAL RATIONALE:*
> * *Why It's Right:* If-else provides a two-way branch based on a condition.
> * *Why Distractors Fail:* Loops are for repetition; switch is for multiple comparisons.
> * *Core Takeaway:* If-else handles true/false branching.
---
*QUESTION 5:*
What will the following Python code output: print("Hello" + " World")
A) Hello World
B) HelloWorld
C) Hello + World
D) Error
> 🎯 *CORRECT ANSWER:* A) Hello World
> 💡 *CLINICAL RATIONALE:*
> * *Why It's Right:* The plus operator concatenates strings with a space.
> * *Why Distractors Fail:* HelloWorld would occur without the space; + is not printed.
> * *Core Takeaway:* String concatenation joins strings.
---
, *QUESTION 6:*
Which operator is used to compare two values for equality in most programming languages?
A) =
B) ==
C) !=
D) <=
> 🎯 *CORRECT ANSWER:* B) ==
> 💡 *CLINICAL RATIONALE:*
> * *Why It's Right:* == is the equality comparison operator.
> * *Why Distractors Fail:* = is assignment; != is inequality; <= is less than or equal.
> * *Core Takeaway:* Use == to test equality.
---
*QUESTION 7:*
What is the result of the expression 5 // 2 in Python?
A) 2
B) 2.5
C) 2.0
D) 3
> 🎯 *CORRECT ANSWER:* A) 2
> 💡 *CLINICAL RATIONALE:*
> * *Why It's Right:* // is floor division, returning the integer quotient.
> * *Why Distractors Fail:* 2.5 is true division; 3 is rounding up.
> * *Core Takeaway:* Floor division discards the remainder.