WGU Scripting and Programming Foundations Exam Questions and Answers
Question 5
What is the out of the given pseudocode?
Options:
A.
6
B.
12
C.
15
D.
18
Answer:
C
Explanation:
Explanation:
The pseudocode provided appears to be a loop that calculates the sum of numbers. Without seeing the exact pseudocode, I can deduce based on common programming patterns that if the loop is designed to add numbers from 1 to 5, the sum would be 1 + 2 + 3 + 4 + 5, which equals 15. This is a typical example of a series where the sum of the first n natural numbers is given by the formula
2n(n+1)
, and in this case, with n being 5, the sum is
25(5+1)=15
References: This answer is based on the standard algorithm for the sum of an arithmetic series and common looping constructs in programming. The formula for the sum of the first n natural numbers is a well-known result in mathematics and is often used in computer science to describe the behavior of loops and series calculations.
Question 6
What does a function definition consist of?
Options:
A.
The function's argument values
B.
An invocation of a function's name
C.
A list of all other functions that call the function
D.
The function's name, inputs, outputs, and statements
Answer:
D
Explanation:
Explanation:
A function definition is the blueprint for a block of code designed to perform a specific task. Here's what it includes:
Function Name: A unique name to identify and call the function (e.g., calculate_area).
Inputs (Parameters/Arguments): Values or variables passed into the function when it's called (e.g., width, height).
Outputs (Return Value): The result the function produces after processing (e.g., the calculated area). This value may or may not be explicitly returned.
Statements (Function Body): Contains the code that performs the actions and calculations within the function.
Question 7
What would a string be used to store?
Options:
A.
A positive whole number
B.
The word "positive"
C.
A true/false indication of whether a number is composite
D.
A positive number between 2 and 3
Answer:
B
Explanation:
Explanation:
In programming, a string is used to store sequences of characters, which can include letters, numbers, symbols, and spaces. Strings are typically utilized to store textual data, such as words and sentences12. For example, the word “positive” would be stored as a string. While strings can contain numbers, they are not used to store numbers in their numeric form but rather as text. Therefore, options A, C, and D, which involve numbers or boolean values, would not be stored as strings unless they are meant to be treated as text.
References: 1: Coderslang: Become a Software Engineer - What is a String in Programming. 2: Wikipedia - String (computer science).
Question 8
Which phase of a waterfall approach defines specifies on how to build a program?
Options:
A.
Analysis
B.
Implementation
C.
Design
D.
Testing
Answer:
C
Explanation:
Explanation:
In the Waterfall approach to software development, the phase that defines and specifies how to build a program is the Design phase. This phase follows the initial Analysis phase, where the requirements are gathered, and precedes the Implementation phase, where the actual coding takes place. During the Design phase, the software’s architecture, components, interfaces, and data are methodically planned out. This phase translates the requirements into a blueprint for constructing the software, ensuring that the final product will meet the specified needs.
References: The stages of the Waterfall methodology and their purposes are well-documented in project management and software engineering literature. Atlassian provides a comprehensive guide on the Waterfall methodology, detailing each phase and its significance1. Built In also offers insights into the Waterfall methodology, including the systematic structure it provides for planning, organization, design, and testing2. These sources affirm the role of the Design phase in the Waterfall approach as the stage where the program’s construction is defined.