Limited-Time Offer: Enjoy 50% Savings! Ends in 00h 00m 00s Coupon code: 50OFF
Skip to content

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

Page: 1 / 14 Total 138 questions

Want more questions? Get Premium Access.

Question 1

The steps in an algorithm to build a picnic table are given:

Measure and mark the lumber cuts that need to be made.

Buy the needed materials.

Determine the needed materials.

Cut the lumber to the proper dimensions.

Assemble the pieces and paint.Which two steps of the algorithm should be switched to make the algorithm successful?

Correct Answer: C. 2 and 3
Explanation:

Comprehensive and Detailed Explanation From Exact Extract:

To build a picnic table, the steps must be performed in a logical order. According to foundational programming principles (e.g., Certiport Scripting and Programming Foundations Study Guide), algorithms require correct sequencing to achieve the desired outcome. We analyze the steps to identify the logical order and find which steps are misplaced.

Current Order:

Measure and mark lumber cuts.

Buy the needed materials.

Determine the needed materials.

Cut the lumber to the proper dimensions.

Assemble the pieces and paint.

Logical Order Analysis:

Determine the needed materials (Step 3) must come first, as you need to know what materials are required before purchasing them.

Buy the needed materials (Step 2) follows, as you purchase the materials identified.

Measure and mark the lumber cuts (Step 1) comes next, as you need the materials on hand to measure and mark.

Cut the lumber to the proper dimensions (Step 4) follows marking.

Assemble the pieces and paint (Step 5) is the final step.

Issue: Step 3 (determine materials) is after Step 2 (buy materials), which is illogical because you must know what to buy before purchasing. Switching Steps 2 and 3 corrects this:

New order: 1, 3, 2, 4, 5.

Option A: '1 and 3.' Incorrect. Switching Step 1 (measure/mark) and Step 3 (determine materials) places measuring before determining materials, which is illogical since you need materials first.

Option B: '1 and 2.' Incorrect. Switching Step 1 (measure/mark) and Step 2 (buy materials) places buying before determining materials (Step 3), which remains out of order.

Option C: '2 and 3.' Correct. Switching Step 2 (buy materials) and Step 3 (determine materials) results in: 1, 3, 2, 4, 5, where materials are determined before buying.

Option D: '2 and 4.' Incorrect. Switching Step 2 (buy materials) and Step 4 (cut lumber) places cutting before determining materials, which is illogical.

Certiport Scripting and Programming Foundations Study Guide (Section on Algorithms and Sequencing).

General Algorithm Design Principles (logical step ordering).


Question 2

An algorithm should output ''OK'' if a number is between 98.3 and 98.9, else the output is ''Net OK''

Which test is a valid test of the algorithm?

Correct Answer: B. Input 98.6. Ensure output is 'OK '
Explanation:

The algorithm is designed to output ''OK'' if the input number is within the range of 98.3 to 98.9. Therefore, the valid test would be one that checks if the algorithm correctly identifies a number within this range and outputs ''OK''. Option B provides an input of 98.6, which falls within the specified range, and expects the correct output of ''OK'', making it a valid test case for the algorithm.


1: Stack Overflow - How to decide test cases for unit tests?2: Analytics Vidhya - Writing Test Cases for Machine Learning systems3: LinkedIn - How to Choose the Best Test Cases for Your Algorithm

Question 3

What are two examples of valid function calls?

Choose 2 answers.

Correct Answer: C. round(4.723, 2); D. PrintSample()
Explanation:

Comprehensive and Detailed Explanation From Exact Extract:

A valid function call invokes a function by its name, providing the required number and type of arguments in the correct syntax. According to foundational programming principles (e.g., Certiport Scripting and Programming Foundations Study Guide), function calls must follow the language's syntax rules, typically function_name(arguments).

Option A: 'function sample(float 2.0).' This is incorrect. This resembles a function definition (declaring a function named sample with a parameter), not a function call. A call would be sample(2.0).

Option B: 'GetHeight(integer 3, 4).' This is incorrect. The syntax integer 3 is invalid in most languages for a function call. A correct call might be GetHeight(3, 4), assuming GetHeight accepts two integers. The inclusion of type keywords (integer) is not typical in function calls.

Option C: 'round(4.723, 2).' This is correct. In languages like Python, round(4.723, 2) is a valid call to the built-in round function, which takes a float and an integer (number of decimal places) and returns a rounded value (e.g., 4.72).

Option D: 'PrintSample().' This is correct. Assuming PrintSample is a defined function with no parameters, PrintSample() is a valid call (e.g., in Python: def PrintSample(): print('Sample')).

Certiport Scripting and Programming Foundations Study Guide (Section on Functions and Function Calls).

Python Documentation: ''Built-in Functions'' (https://docs.python.org/3/library/functions.html#round).

W3Schools: ''C Functions'' (https://www.w3schools.com/c/c_functions.php).


Question 4

A function should return 0 if a number, N is even and 1 if N is odd.

What should be the input to the function?

Correct Answer: D. N
Explanation:

In the context of writing a function that determines whether a given numberNis even or odd, the input to the function should be the number itself, represented by the variableN. The function will then perform the necessary logic to determine whetherNis even or odd and return the appropriate value (0 for even, 1 for odd).

Here's how the function might look in Python:

Python

def check_even_odd(N):

'''

Determines whether a given number N is even or odd.

Args:

N (int): The input number.

Returns:

int: 0 if N is even, 1 if N is odd.

'''

if N % 2 == 0:

return 0 # N is even

else:

return 1 # N is odd

# Example usage:

number_to_check = 7

result = check_even_odd(number_to_check)

print(f'The result for {number_to_check} is: {result}')

AI-generated code. Review and use carefully.More info on FAQ.

In this example, ifnumber_to_checkis 7, the function will return 1 because 7 is an odd number.


No specific external references are needed for this basic concept, as it is fundamental to programming and mathematics.

Question 5

Which kind of language is HTML?

Correct Answer: B. Markup
Explanation:

Comprehensive and Detailed Explanation From Exact Extract:

HTML (HyperText Markup Language) is a standard for structuring content on the web. According to foundational programming principles, HTML is a markup language, not a programming language, and does not involve typing (dynamic or static) or OOP.

Option A: 'Dynamically typed.' This is incorrect. HTML is not a programming language and does not involve variables or typing. Dynamic typing applies to languages like Python or JavaScript.

Option B: 'Markup.' This is correct. HTML is a markup language used to define the structure of web content using tags (e.g.,

,

).

Option C: 'Statically typed.' This is incorrect. HTML does not involve typing, as it is not a programming language. Static typing applies to languages like C or Java.

Option D: 'Object-oriented.' This is incorrect. HTML lacks OOP features like classes, inheritance, or polymorphism, as it is designed for content structuring, not programming.

Certiport Scripting and Programming Foundations Study Guide (Section on Markup Languages).

W3Schools: ''HTML Introduction'' (https://www.w3schools.com/html/html_intro.asp).

Mozilla Developer Network: ''HTML Basics'' (https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/HTML_basics).


Question 6

A sample function is shown:

What is returned for F (3)?

Correct Answer: A. 12
Explanation:

Let's evaluate F(3):

F(3) = (4 * 3) - 8

F(3) = 12 - 8

F(3) = 4


Question 7

Review the following sequence diagram:

What does a sequence diagram do?

Correct Answer: A. Shows interactions awl indicates an order of events
Explanation:

A sequence diagram is a type of interaction diagram used in software engineering to model the interactions between objects within a system over time. It shows how objects interact with each other and the order in which those interactions occur. The sequence diagram is organized along two dimensions: horizontally to represent the objects involved, and vertically to represent the time sequence of interactions.This allows the diagram to depict not only the interactions but also the sequence of events as they occur over time12345.

Option B is incorrect because a sequence diagram does indeed specify an order of events. Option C is incorrect as sequence diagrams do not show static elements of software but rather the dynamic interactions. Option D is also incorrect because a sequence diagram does show all interactions along with their order.


Question 8

A team of programmers describes the objects and functions in a program that compresses files before splitting the objects.

Which two waterfall approach phases are involved?

Correct Answer: D. Design and implementation
Explanation:

The Waterfall Model is a sequential design process used in software development, where progress is seen as flowing steadily downwards through several phases like a waterfall. In the context of the question, describing the objects and functions in a program that compresses files before splitting the objects involves two specific phases:

Design Phase: This is where the system's architecture, components, interfaces, and data are all defined. The team would design the objects and functions necessary for the file compression program during this phase.

Implementation (or Development) Phase: Following the design, the actual code is written during the implementation phase. The objects and functions described in the design phase are created and tested to ensure they work as intended.

These two phases are critical in the Waterfall approach for transitioning from an abstract understanding of the problem to a concrete implementation in code. The analysis phase is more about understanding the problem and requirements, while testing is a separate phase that comes after implementation.


GeeksforGeeks article on Waterfall Model1.

Built In's explanation of Waterfall Methodology2.

Forbes Advisor's overview of Waterfall Methodology3.

Question 9

A programmer is writing code using C. Which paradigm could the programmer be using?

Correct Answer: B. A procedural paradigm using sialic types
Explanation:

C is a programming language that primarily follows the procedural programming paradigm1.This paradigm is a subset of imperative programming and emphasizes on procedure in terms of the underlying machine model1.It involves writing a sequence of instructions to tell the computer what to do step by step, and it relies on the concept of procedure calls, where procedures, also known as routines, subroutines, or functions, are a set of instructions that perform a specific task1.

The procedural paradigm in C uses static typing, where the type of a variable is known at compile time1. This means that the type of a variable is declared and does not change over time, which is in contrast to dynamic typing, where the type can change at runtime.C's type system requires that each variable and function is explicitly declared with a type and it does not support dynamic typing as seen in languages like Python or JavaScript1.


Question 10

What is the outcome for the given algorithm? Round to the nearest tenth, if necessary.

Correct Answer: A. 5.0
Explanation:

Initialize two variables:xandCountto zero.

Iterate through each number in theNumList.

For each number in the list:

Add the number tox.

IncrementCountby one.

After processing all numbers in the list, calculate the average:

Average =x / Count.

TheNumListcontains the following integers: [1, 3, 5, 6, 7, 8].

Calculating the average: (1 + 3 + 5 + 6 + 7 + 8) / 6 = 30 / 6 = 5.0.

However, none of the provided options match this result. It seems there might be an error in either the options or the calculation.