AND ANSWERS 2026 .
WGU D278 Scripting and Programming Foundations - 200 Practice Questions
Question 1
A car drove 200 miles using 10 gallons of fuel. Which operation should be used to
compute the miles per gallon, which is 20?
A. Addition
B. Subtraction
C. Multiplication
D. Division
Answer: D
Rationale: Division is used to compute miles per gallon by dividing the distance
traveled (200 miles) by the fuel used (10 gallons), resulting in 20 mpg. This is a
rate calculation where the total distance is divided by the total fuel consumed .
Question 2
Which operator should be used to determine if a number is evenly divisible by 5?
,A. +
B. -
C. *
D. %
Answer: D
Rationale: The modulus operator (%) returns the remainder after division. If a
number modulo 5 equals 0, the number is evenly divisible by 5. This is commonly
used in programming for checking divisibility and in loop conditions .
Question 3
A variable should hold a person's height in meters. Which data type should the
variable be?
A. Integer
B. Float
C. String
D. Boolean
,Answer: B
Rationale: Float (floating-point) data types store numbers with decimal points.
Height in meters typically requires decimal precision (e.g., 1.75 meters). Integers
only store whole numbers and would lose precision .
Question 4
A variable should hold the names of all past U.S. presidents. Which data type
should the variable be?
A. Integer array
B. Float array
C. String array
D. Boolean array
Answer: C
, Rationale: Names are text data, which should be stored as strings. Since multiple
names are needed, an array of strings is appropriate. This allows storing and
accessing multiple text values efficiently .
Question 5
A program uses the number of seconds in a minute in various calculations. How
should the item that holds the number of seconds in a minute be declared?
A. Constant float userTime
B. Variable float userTime
C. Constant integer secondsPerMinute
D. Variable integer secondsPerMinute
Answer: C
Rationale: The number of seconds in a minute (60) is a fixed, unchanging value. It
should be declared as a constant integer. Constants improve code readability and
prevent accidental modification of values that should remain fixed .
Question 6