Scripting and Programming –
Foundations 2026/2027 | Complete
Practice Questions and Answers
Description: This comprehensive revision guide contains 200 multiple-choice questions
covering all key domains of the WGU D278 Scripting and Programming – Foundations
course. Topics include variables, data types, operators, control structures, loops,
functions, arrays, strings, file I/O, object-oriented programming, algorithms,
debugging, and scripting fundamentals. Each question includes the correct answer
marked with ✅ for effective self-assessment and exam preparation.
Keywords: WGU D278, Scripting and Programming Foundations, Pre-Assessment, MCQ,
Practice Questions, Programming Fundamentals, Algorithms, Data Types, Control
Structures, Functions, Arrays, OOP, Debugging, 2026, 2027.
1. Which of the following best defines a variable in programming?
A) A fixed value that cannot be changed
B) A named storage location in memory that can hold a value ✅
C) A type of loop
D) A function that returns a value
,2. What is the primary purpose of a data type in programming?
A) To define the color of text
B) To specify the kind of data a variable can hold and the operations that can be
performed on it ✅
C) To increase the speed of the program
D) To create graphical user interfaces
3. Which data type is used to store a single character?
A) String
B) Integer
C) Char ✅
D) Boolean
4. What is the value of a Boolean variable?
A) Any number
B) True or False ✅
C) A single letter
D) A decimal number
5. Which of the following is an example of a floating-point data type?
A) 42
B) "Hello"
C) 3.14 ✅
D) True
6. What is the result of the expression 7 % 3?
A) 2
B) 1 ✅
,C) 2.33
D) 0
7. Which operator is used for exponentiation in many programming languages?
A) ^
B) ** ✅
C) //
D) %%
8. What is the purpose of the assignment operator (=)?
A) To compare two values
B) To assign a value to a variable ✅
C) To add two numbers
D) To declare a function
9. Which of the following is a logical operator?
A) +
B) && ✅
C) =
D) %
10. What does the expression (5 > 3) && (2 < 4) evaluate to?
A) True ✅
B) False
C) 5
D) 2
11. What is the output of the following code? int x = 5; x += 3; print(x);
A) 5
B) 3
, C) 8 ✅
D) 2
12. Which control structure is used to execute a block of code repeatedly based on
a condition?
A) If statement
B) Loop ✅
C) Function
D) Array
13. What is the correct syntax for an if statement in most languages?
A) if (condition) { } ✅
B) if condition then { }
C) if { condition }
D) if: condition
14. Which loop is guaranteed to execute at least once?
A) For loop
B) While loop
C) Do-while loop ✅
D) Foreach loop
15. What is the purpose of a break statement in a loop?
A) To continue to the next iteration
B) To exit the loop immediately ✅
C) To restart the loop
D) To pause the loop
16. What does the continue statement do in a loop?