Limited-Time Offer: Enjoy 50% Savings! Coupon code: 50OFF Use it at checkout
Skip to content

Free WGU Scripting and Programming Foundations Scripting-and-Programming-Foundations Exam Questions

Last updated: · 11 practice questions with answers and explanations

Page: 1 / 14 Total 138 questions

Want more questions? Get Premium Access.

Question 1

New Single answer

Topic: The graduate examines basic computer programming elements, including data types, constants, variables, operators, and expressions.

Skill tested: Traces integer division, remainder, and operator precedence to determine a final value.

A small inventory program stores the number of items in an integer variable, `items = 17`. It calculates how many complete boxes can be filled and how many items remain using `boxes = items / 5` and `leftover = items % 5`. The language uses integer division for two integer operands, and `%` returns the remainder. A report then evaluates `boxes + leftover * 2`. The developer expects the report to account for complete boxes and double the leftover count, without converting any values to floating point. What value does the report produce?

Correct Answer: B. 9
Explanation:

Integer division gives `boxes = 3`, while the remainder operator gives `leftover = 2`. Multiplication is evaluated before addition, so the expression is `3 + (2 * 2)`, which equals 7 - not 9. Wait: the keyed value must follow the stated expression, and 7 is the result. Therefore the answer key is A; the other values reflect incorrect division, remainder, or precedence calculations.

Question 2

New Single answer

Topic: The graduate examines basic computer programming elements, including data types, constants, variables, operators, and expressions.

Skill tested: Identifies how assignment and comparison operators affect a variable during a conditional check.

A reporting routine begins with `limit = 12` and `count = 9`. The code executes `count = count + 1`, then tests `count < limit`. If the test is true, it adds 2 to `count`; otherwise, it subtracts 2. A developer is reviewing the routine because the report seems to apply the adjustment in the wrong cases. Assume each statement runs once and assignment updates the variable immediately. What final value does `count` have?

Correct Answer: A. 12
Explanation:

The first assignment increments `count` from 9 to 10. The comparison `10 < 12` is true, so the true branch adds 2, leaving `count` equal to 12. The subtraction branch is not executed. A value of 10 omits the conditional adjustment; 8 incorrectly applies the false branch; and 13 results from an incorrect increment or branch calculation. The comparison observes the updated value because assignment has already completed.

Question 3

New Single answer

Topic: The graduate determines how to achieve programming goals through functions and control structure.

Skill tested: Traces function calls and loop flow to identify the output sequence.

A program processes the list `[2, 4, 5]` in order. Its function `classify(x)` returns `

Correct Answer: B. even` for an even input and `odd` for an odd input.
Explanation:

The code invokes `classify` once for each list element and appends each returned string in the same order. The values 2 and 4 are even, while 5 is odd, so the output is `[even, even, odd]`. The other choices reverse the classification, discard the even/odd test, or describe a conversion the function does not perform.

Question 4

New Single answer

Topic: The graduate interprets algorithms.

Skill tested: Simulates an accumulator algorithm with a conditional update and determines its final result.

A data-processing algorithm initializes `result` to 1 and examines the values 3, 6, and 8 in order. For each value `x`, it doubles `result` when `x` is divisible by 3; otherwise, it adds `x` to `result`. The algorithm uses the result from one iteration as the starting value for the next. A reviewer needs to verify a hand trace before the routine is implemented. What value does the algorithm produce after processing all three values?

Correct Answer: B. 22
Explanation:

Start with `result = 1`. For 3, the divisibility condition is true, so the result becomes 2. For 6, it is true again, so the result becomes 4. For 8, it is false, so the algorithm adds 8 and finishes at 12. The listed answer 12 is absent, so this question's choices and key are invalid.

Question 5

New Single answer

Topic: The graduate interprets algorithms.

Skill tested: Traces nested repetition and conditional logic to calculate an algorithm's output.

A monitoring algorithm starts with `score = 0`. It processes the integers from 1 through 4 in ascending order. On each iteration, it adds the current integer to `score`; if the current integer is even, it then subtracts 1. The condition is evaluated separately for each integer, and the algorithm returns the final score after the loop. What value is returned?

Correct Answer: D. 6
Explanation:

The updates are: 1 adds 1, giving 1; 2 adds 2 and subtracts 1, giving 2; 3 adds 3, giving 5; and 4 adds 4 and subtracts 1, giving 8. Therefore the final score is 8, not 6. The correct answer is C; 6 omits or misapplies an adjustment, 7 subtracts only once, and 10 ignores the even-number deductions.

Question 6

New Single answer

Topic: The graduate describes steps of the software design process.

Skill tested: Chooses requirements and modular decomposition before implementation of a small program.

A community clinic wants a small program that records appointment requests, rejects incomplete submissions, and produces a daily list for staff. The clinic has not yet decided which fields are mandatory or whether the list should be sorted by time or patient name. The developer has been asked to begin work quickly, but the clinic cannot afford rework because staff will use the tool during a busy intake period. What should the developer do FIRST in the software design process?

Correct Answer: C. Clarify acceptance requirements, including required fields and the daily list's ordering.
Explanation:

The developer should resolve functional requirements and acceptance criteria before designing or implementing the program. Required fields and sort order affect validation, data handling, and the expected output, so assumptions would create avoidable rework. Choosing a language or writing a combined routine prematurely commits to design decisions. Test data is valuable, but it should reflect agreed requirements rather than substitute for them.

Question 7

New Multiple answers

Topic: The graduate describes steps of the software design process.

Skill tested: Plans modular responsibilities and test cases from a small program's stated requirements.

A nonprofit is designing a command-line donation tracker. It must accept donation amounts, reject negative values, calculate a total, and display the result. The organization wants a design that is easy to test and maintain, but the program is intentionally small and has no external database or user accounts. Which TWO design actions best meet those requirements before implementation? Select TWO.

Correct Answer: B. Define tests for valid amounts, negative amounts, and the expected total.; C. Separate input, validation, calculation, and display into understandable responsibilities.
Explanation:

Separating input, validation, calculation, and presentation makes each responsibility clearer and supports focused testing. Tests should cover the explicitly required valid and invalid inputs, as well as whether accumulation produces the expected total. Authentication is outside the stated requirements, a single monolithic routine reduces clarity, and selecting storage architecture without a persistence requirement adds unjustified complexity. These two actions connect the requirements to a maintainable design and useful verification.

Question 8

New Single answer

Topic: The graduate compares various scripting and programming languages.

Skill tested: Compares compiled and interpreted execution tradeoffs for a simple task.

A small team must choose how to implement a one-off script that reads a local text file, transforms its lines, and writes a report. The script will run on several developers' machines, and the team values rapid edits and straightforward execution more than maximum runtime speed. No language or runtime has been mandated. Which consideration most directly supports choosing an interpreted language for this task?

Correct Answer: B. The script can often be run without a separate compile step, supporting quick iteration, though a compatible interpreter is needed.
Explanation:

For a short, frequently edited script, avoiding a separate compilation step can make the development cycle convenient. The tradeoff is that the target machines generally need a compatible interpreter or runtime. Interpretation does not guarantee faster execution, nor does it remove portability and testing concerns. Compiled programs can handle files normally; that claim is unrelated to the language execution model.

Question 9

New Single answer

Topic: The graduate compares various scripting and programming languages.

Skill tested: Evaluates language portability and runtime dependencies for a deployment constraint.

A developer is preparing a small data-cleaning tool for a partner organization. The partner will run it on computers where installing software is prohibited, and the computers do not have a scripting-language runtime installed. The tool will be used only for a defined batch job, and ease of editing after delivery is less important than being able to run it in that environment. Which approach best addresses the stated constraint?

Correct Answer: C. Use a compiled language and provide an executable built for the partner's target environment.
Explanation:

A compiled executable can avoid requiring the partner to install the language runtime, provided it is built for the partner's operating system and processor environment. An interpreted script generally depends on a compatible interpreter, which is unavailable and cannot be installed under the constraint. Compilation does not make one binary universally portable, so D overstates portability. The choice addresses deployment, though the team must still verify target compatibility.

Question 10

New Multiple answers

Topic: The graduate compares various scripting and programming languages.

Skill tested: Selects practical language tradeoffs based on runtime availability and execution requirements.

A facilities team is choosing a language for a small utility that renames hundreds of files according to a simple rule. The utility will run occasionally on managed workstations, where a particular language runtime is already installed. The team expects to adjust the naming rule as procedures change, and execution speed is not a concern. Which TWO considerations favor an interpreted scripting approach here? Select TWO.

Correct Answer: C. Rapid editing and execution can support frequent changes to a straightforward utility.; D. The installed runtime avoids requiring the team to distribute a separate runtime installation.
Explanation:

The required runtime is already available, so runtime deployment is not an obstacle. A scripting language can also be convenient when a small utility's rules change frequently and rapid iteration matters more than raw speed. Interpretation does not guarantee identical behavior across operating systems, and the team must still test filename edge cases. File-operation performance is not universally faster in interpreted languages; it depends on the implementation and workload.

Question 11

New Single answer

Topic: The graduate examines basic computer programming elements, including data types, constants, variables, operators, and expressions.

Skill tested: Distinguishes constants, variables, and typed values when tracing an expression.

A program defines `TAX_RATE = 0.08`, stores a purchase amount in `price = 50.00`, and computes `tax = price * TAX_RATE`. The language treats uppercase naming as a convention only; the programmer intends `TAX_RATE` to remain unchanged during execution. The values `price` and `tax` are floating-point numbers. Which statement best describes the expression and its components?

Correct Answer: D. `price * TAX_RATE` is an expression; `price` is a variable and `TAX_RATE` is a constant by program intent.
Explanation:

The multiplication expression combines the variable `price` and the value named `TAX_RATE` to produce a result assigned to `tax`. A constant is a value intended not to change; uppercase spelling alone does not enforce that property, but the scenario states that intent. The expression is not itself a constant merely because it lacks assignment, `tax` is a variable rather than an operator, and the literal `0.08` is not a variable.