WGU Scripting and Programming Foundations Exam Questions

Page: 1 / 14
Total 138 questions
Question 1

Which data type should be used to hold the value of a person's body temperature in Fahrenheit?



Answer : C

Comprehensive and Detailed Explanation From Exact Extract:

Body temperature in Fahrenheit typically includes decimal precision (e.g., 98.6F). According to foundational programming principles, a floating-point type is suitable for values with decimal components.

Option A: 'Integer.' This is incorrect. Integers cannot store decimal values, and body temperature often requires precision (e.g., 98.6 99).

Option B: 'String.' This is incorrect. While a string could store '98.6' as text, it's not suitable for numerical calculations (e.g., averaging temperatures).

Option C: 'Float.' This is correct. A floating-point type (float) can store decimal values like 98.6, making it ideal for body temperature. For example, in C: float temp = 98.6;.

Option D: 'Boolean.' This is incorrect. Booleans store true/false values, not numerical temperatures.

Certiport Scripting and Programming Foundations Study Guide (Section on Data Types).

Python Documentation: ''Floating Point Types'' (https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex).

W3Schools: ''C Data Types'' (https://www.w3schools.com/c/c_data_types.php).


Question 2

Refer to the exhibit.

What is the output of the given flowchart if the input is 54?



Answer : A

Start with the input value (in this case, 54).

Follow the flowchart's paths and apply the operations as indicated by the symbols and connectors.

Therectanglesrepresent processes or actions to be taken.

Thediamondsrepresent decision points where you will need to answer yes or no and follow the corresponding path.

Theparallelogramsrepresent inputs/outputs within the flowchart.

Use the input value and apply the operations as you move through the flowchart from start to finish.


Flowchart analysis is based on the understanding of flowchart symbols and their meanings, which can be found in resources such as ASQ's guide to flowcharts1and Asana's explanation of flowchart symbols2.

To determine the correct answer, you would need to apply the input value of 54 to the flowchart and follow the steps until you reach the end, noting the output value. If you encounter any decision points, evaluate the condition with the current value and choose the path accordingly. By the end of the flowchart, you should have the final output value which corresponds to one of the options provided.

Question 3

A program allows the user to play a game. At the end of each game, the program asks the user if they want to play again.

Which programming structure on its own is appropriate to accomplish this task?



Answer : C

The most appropriate programming structure to repeatedly ask a user if they want to play a game again is a while loop. This is because a while loop can execute a block of code as long as a specified condition is true. In this case, the condition would be whether the user wants to play again or not. The while loop will continue to prompt the user after each game and will only exit if the user indicates they do not want to play again. This makes it an ideal choice for tasks that require repeated execution based on user input.

For loops are generally used when the number of iterations is known beforehand, which is not the case here as we cannot predict how many times a user will want to play the game. Nested for loops and if-else statements are not suitable for repeating tasks based on dynamic user input.


Loops in Programming - GeeksforGeeks1

Use the right loop to repeat tasks - Learn programming with Java - OpenClassrooms2

Using For and While Loops for User Input in Python - Stack Abuse3

Question 4

Which phase of an Agile approach would create a function that calculates shipping costs based on an item's weight and delivery zip code?



Answer : C

Comprehensive and Detailed Explanation From Exact Extract:

In Agile software development, the process is iterative, with phases including analysis, design, implementation, and testing. According to foundational programming principles and Agile methodologies (e.g., Certiport Scripting and Programming Foundations Study Guide, Agile Manifesto), creating a function (writing code) occurs during the implementation phase.

Agile Phases Overview:

Analysis: Gathers requirements (e.g., user stories like ''calculate shipping costs based on weight and zip code'').

Design: Plans the technical solution (e.g., specifying the function's signature, inputs, and outputs).

Implementation: Writes and integrates the code (e.g., coding the function).

Testing: Verifies the code meets requirements.

Option A: 'Testing.' This is incorrect. Testing verifies the function's correctness, not its creation.

Option B: 'Analysis.' This is incorrect. Analysis defines the requirement for the function (e.g., what it should do), not the coding.

Option C: 'Implementation.' This is correct. In Agile, writing the function to calculate shipping costs (e.g., calculateShipping(weight, zipCode)) happens during implementation, where code is developed based on the design.

Option D: 'Design.' This is incorrect. Design specifies the function's structure (e.g., parameters, return type), but the actual coding occurs in implementation.

Certiport Scripting and Programming Foundations Study Guide (Section on Agile Development Phases).

Agile Manifesto: ''Working Software'' (http://agilemanifesto.org/).

Sommerville, I., Software Engineering, 10th Edition (Chapter 4: Agile Software Development).


Question 5

Which expression evaluates to 3.7 if float x = 17.0?



Answer : D

A .X + 2 / 10:

First, calculate2 / 10, which is0.2.

Then addx (17.0)to0.2, resulting in17.2. This does not equal3.7.

B .(2 + x) / 10.0:

First, add2andx (17.0), which gives19.0.

Then divide19.0by10.0, resulting in3.7.

C .X + 2.0 / 10:

First, calculate2.0 / 10, which is0.2.

Then addx (17.0)to0.2, resulting in17.2. This does not equal3.7.

D .2 + x / 10:

First, dividex (17.0)by10, which gives1.7.

Then add2to1.7, resulting in3.7.

Therefore, optionBis the correct expression.


Mathway - Math Calculator

Quizlet - Scripting and Programming Actual FINAL PREP- Foundations

Question 6

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?



Answer : B

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 7

The steps in an algorithm to find the maximum of integers a and b are given.

Which two steps of the algorithm should be switched to make the algorithm successful?



Answer : C

The variablemaxshould be declared before it is used. So, the corrected algorithm would be:

Declare variable max.

Set max = a.

If b > max, set max = b.

Put max to output.

This way, the variablemaxis declared before being assigned the value ofa, and the rest of the algorithm can proceed as given. Thank you for the question! Let me know if you have any other queries.


Page:    1 / 14   
Total 138 questions