WGU D278 – Scripting and Programming
Foundations Full Actual Exam | Updated 2025
Edition
Exam Overview
This complete practice exam has been carefully designed to reflect the structure, style, and
content focus of the official WGU D278: Scripting and Programming – Foundations
assessment.
It includes:
Topics Covered
✅ Python syntax and variables
✅ Data types and operators
✅ Conditional logic and loops
✅ Functions, scope, and parameters
✅ Lists, tuples, dictionaries, and sets
✅ Input/output operations
✅ Exception handling
✅ File processing
✅ Object-oriented programming concepts
✅ Algorithmic logic and pseudocode
1. What is the output of the following code?
x = 5
y = 10
print(x + y)
A) 15
B) 15
C) 510
D) Error
✅ Rationale: Addition between integers returns their sum, 15.
,2. Which of the following is a valid variable name in Python?
A) 2ndName
B) my-name
C) my_name
D) class
✅ Rationale: Variables cannot start with a digit or use hyphens. class is a reserved keyword.
3. What is the output?
x = "5"
y = 2
print(x * y)
A) 10
B) Error
C) 55
D) '10'
✅ Rationale: String multiplied by integer repeats the string — "5" * 2 = "55".
4. Which data type is immutable in Python?
A) List
B) Dictionary
C) Tuple
D) Set
✅ Rationale: Tuples cannot be changed after creation.
5. What is the correct output?
for i in range(3):
print(i)
A) 1 2 3
B) 0 1 2
,C) 0 1 2 3
D) 3
✅ Rationale: range(3) generates 0, 1, 2.
6. Which keyword defines a function in Python?
A) func
B) def
C) define
D) function
✅ Rationale: def is the keyword used to declare a function.
7. What is printed by this code?
def greet(name="Student"):
print("Hello", name)
greet()
A) Error
B) Hello
C) Hello Student
D) Hello None
✅ Rationale: Default argument is used when no argument is passed.
8. What is the output?
nums = [2, 4, 6]
nums.append(8)
print(nums)
A) [2, 4, 6]
B) [2, 4, 6, 8]
C) [8, 6, 4, 2]
D) [2, 4, 6][8]
✅ Rationale: .append() adds an element to the end of a list.
, 9. What is the result of bool("")?
A) True
B) False
C) None
D) Error
✅ Rationale: Empty strings evaluate to False in Boolean context.
10. Which symbol is used for integer division in Python?
A) /
B) //
C) %
D) **
✅ Rationale: // returns integer (floor) division results.
11. What is the output of the following code?
x = 3
if x > 2:
print("High")
else:
print("Low")
A) High
B) Low
C) 2
D) Error
✅ Rationale: The condition x > 2 is true, so it prints “High”.
12. Which of these statements will create a list?
A) list = (1, 2, 3)
B) list = [1, 2, 3]
Foundations Full Actual Exam | Updated 2025
Edition
Exam Overview
This complete practice exam has been carefully designed to reflect the structure, style, and
content focus of the official WGU D278: Scripting and Programming – Foundations
assessment.
It includes:
Topics Covered
✅ Python syntax and variables
✅ Data types and operators
✅ Conditional logic and loops
✅ Functions, scope, and parameters
✅ Lists, tuples, dictionaries, and sets
✅ Input/output operations
✅ Exception handling
✅ File processing
✅ Object-oriented programming concepts
✅ Algorithmic logic and pseudocode
1. What is the output of the following code?
x = 5
y = 10
print(x + y)
A) 15
B) 15
C) 510
D) Error
✅ Rationale: Addition between integers returns their sum, 15.
,2. Which of the following is a valid variable name in Python?
A) 2ndName
B) my-name
C) my_name
D) class
✅ Rationale: Variables cannot start with a digit or use hyphens. class is a reserved keyword.
3. What is the output?
x = "5"
y = 2
print(x * y)
A) 10
B) Error
C) 55
D) '10'
✅ Rationale: String multiplied by integer repeats the string — "5" * 2 = "55".
4. Which data type is immutable in Python?
A) List
B) Dictionary
C) Tuple
D) Set
✅ Rationale: Tuples cannot be changed after creation.
5. What is the correct output?
for i in range(3):
print(i)
A) 1 2 3
B) 0 1 2
,C) 0 1 2 3
D) 3
✅ Rationale: range(3) generates 0, 1, 2.
6. Which keyword defines a function in Python?
A) func
B) def
C) define
D) function
✅ Rationale: def is the keyword used to declare a function.
7. What is printed by this code?
def greet(name="Student"):
print("Hello", name)
greet()
A) Error
B) Hello
C) Hello Student
D) Hello None
✅ Rationale: Default argument is used when no argument is passed.
8. What is the output?
nums = [2, 4, 6]
nums.append(8)
print(nums)
A) [2, 4, 6]
B) [2, 4, 6, 8]
C) [8, 6, 4, 2]
D) [2, 4, 6][8]
✅ Rationale: .append() adds an element to the end of a list.
, 9. What is the result of bool("")?
A) True
B) False
C) None
D) Error
✅ Rationale: Empty strings evaluate to False in Boolean context.
10. Which symbol is used for integer division in Python?
A) /
B) //
C) %
D) **
✅ Rationale: // returns integer (floor) division results.
11. What is the output of the following code?
x = 3
if x > 2:
print("High")
else:
print("Low")
A) High
B) Low
C) 2
D) Error
✅ Rationale: The condition x > 2 is true, so it prints “High”.
12. Which of these statements will create a list?
A) list = (1, 2, 3)
B) list = [1, 2, 3]