WGU Scripting and Programming Foundations Exam Questions and Answers
It is given that integer x=41 and integer y = 16. What is the value of the expression (x % 8) - y?
Options:
-15
-11
-8
1
Answer:
BExplanation:
The expression ((x % 8) - y) involves the modulo operation and subtraction. The modulo operation finds the remainder when ( x ) is divided by ( 8 ). Given ( x = 41 ), we calculate ( 41 % 8 ) which equals ( 1 ) because ( 41 ) divided by ( 8 ) equals ( 5 ) with a remainder of ( 1 ). Then, we subtract ( y ) (which is ( 16 )) from this remainder:
(41%8)−16=1−16=−15
However, there seems to be a discrepancy here as the calculation shows the answer should be (-15), but this is not an option provided in your question. Please double-check the options or the expression provided.
What is one characteristic of an object-oriented language that is not a characteristic of a procedural or functional language?
Options:
The language is based on the concept of modular programming and the calling of a subroutine.
The language is optimized for recursive programming.
The language supports decomposing a program into objects that interact with one another.
The language treats programs as evaluating mathematical functions.
Answer:
CExplanation:
One of the fundamental characteristics of object-oriented programming (OOP) is the concept of decomposing a program into objects that interact with one another1. This is distinct from procedural and functional programming paradigms, which do not inherently structure programs as a collection of objects. In OOP, objects are instances of classes and contain both data (attributes) and code (methods). These objects encapsulate data and operations and can interact with each other through methods, allowing for concepts such as inheritance, polymorphism, and encapsulation12.
In contrast, procedural programming is characterized by a focus on procedures or routines to perform tasks, and functional programming treats computation as the evaluation of mathematical functions without side effects or state changes2. Neither paradigm organizes code around objects with encapsulated data and methods, which is a defining feature of OOP1.
A program calculates the average miles per gallon given miles traveled and gas consumed. How should the item that holds the miles per gallon be declared?
Options:
Variable float milesTraveled
Constant float milesPerGallon
Constant float milesTraveled
Variable float milesPerGallon
Answer:
DExplanation:
Comprehensive and Detailed Explanation From Exact Extract:
Miles per gallon (MPG) is calculated as miles traveled divided by gallons consumed, typically resulting in a decimal value (e.g., 25.5 MPG). According to foundational programming principles, MPG should be a variable (as it is computed and may change) and a floating-point type to handle decimals.
Option A: "Variable float milesTraveled." This is incorrect. While miles traveled may be a float variable, the question asks for the declaration of MPG, not miles traveled.
Option B: "Constant float milesPerGallon." This is incorrect. MPG is calculated and may vary with different inputs, so it should be a variable, not a constant (const).
Option C: "Constant float milesTraveled." This is incorrect. The question focuses on MPG, not miles traveled, and constants are inappropriate for computed values.
Option D: "Variable float milesPerGallon." This is correct. MPG requires a float to store decimal values (e.g., 22.7) and a variable to allow updates based on new calculations. For example, in C: float milesPerGallon = miles / gallons;.
Certiport Scripting and Programming Foundations Study Guide (Section on Variables and Data Types).
Python Documentation: “Floating Point Arithmetic”
W3Schools: “C Data Types”
What does a function definition consist of?
Options:
The function’s name, inputs, outputs, and statements
A list of all other functions that call the function
An invocation of a function’s name
The function’s argument values
Answer:
AExplanation:
Comprehensive and Detailed Explanation From Exact Extract:
A function definition specifies how a function operates, including its name, parameters (inputs), return type or values (outputs), and the statements it executes. According to foundational programming principles, a function definition is distinct from a function call or its usage.
Option A: "The function’s name, inputs, outputs, and statements." This is correct. A function definition includes:
Name (e.g., myFunction).
Inputs (parameters, e.g., int x, int y).
Outputs (return type or value, e.g., int or return x + y).
Statements (body, e.g., { return x + y; } in C).For example, in Python: def add(x, y): return x + y.
Option B: "A list of all other functions that call the function." This is incorrect. A function definition does not track or include its callers; it defines the function’s behavior.
Option C: "An invocation of a function’s name." This is incorrect. An invocation (call) is when the function is used (e.g., add(2, 3)), not its definition.
Option D: "The function’s argument values." This is incorrect. Argument values are provided during a function call, not in the definition, which specifies parameters (placeholders).
Certiport Scripting and Programming Foundations Study Guide (Section on Function Definitions).
Python Documentation: “Defining Functions”
W3Schools: “C Function Definitions”
Which three statements describe a characteristic of a programming library?
Options:
A library typically must be included before any function in the library is used
A single library normally includes more than one function.
Using libraries will always make a program run less efficiently.
Libraries improve a programmer's productivity.
A single program can only include one library.
One library will contain one function but can have several variables.
Answer:
A, B, DExplanation:
A programming library is a collection of pre-written code that developers can use to optimize tasks and improve productivity. Here’s why the selected statements are correct:
A: Libraries must be included or imported into your program before you can use the functions or objects they contain. This is because the program needs to know where to find the code it’s executing12.
B: A library typically includes multiple functions, objects, or classes that are related to a specific task or area of functionality. This allows developers to reuse code efficiently12.
D: By providing pre-written code, libraries save developers time and effort, which in turn improves their productivity. Instead of writing code from scratch, developers can focus on the unique aspects of their project12.
The other options are incorrect because:
C: While it’s true that poorly designed libraries can affect performance, well-designed libraries can actually make programs more efficient by providing optimized code.
E: A single program can include multiple libraries as needed. There’s no limit to the number of libraries a program can use.
F: Libraries often contain multiple functions and variables, not just one function.
A programmer has been hired to create an inventory system for the books in a library. What is the waterfall phase in which waterfall outlining all the functions that need to be written to support the inventory system?
Options:
Implementation
Testing
Analysis
Design
Answer:
DExplanation:
In the Waterfall model of software development, the phase where all functions that need to be written to support the inventory system would be outlined is the Design phase. This phase is critical as it translates the requirements gathered during the analysis phase into a blueprint for constructing the system. It involves two subphases: logical design and physical design. The logical design subphase is where possible solutions are brainstormed and theorized, while the physical design subphase is when those theoretical ideas and schemas are turned into concrete specifications12.
Which expression evaluates to 3.7 if float x = 17.0?
Options:
X + 2 / 10
(2 + x) / 10.0
X + 2.0 / 10
2 + x / 10
Answer:
DExplanation:
A. X + 2 / 10:
First, calculate 2 / 10, which is 0.2.
Then add x (17.0) to 0.2, resulting in 17.2. This does not equal 3.7.
B. (2 + x) / 10.0:
First, add 2 and x (17.0), which gives 19.0.
Then divide 19.0 by 10.0, resulting in 3.7.
C. X + 2.0 / 10:
First, calculate 2.0 / 10, which is 0.2.
Then add x (17.0) to 0.2, resulting in 17.2. This does not equal 3.7.
D. 2 + x / 10:
First, divide x (17.0) by 10, which gives 1.7.
Then add 2 to 1.7, resulting in 3.7.
Therefore, option B is the correct expression.
Consider the given function:
function K(string s1, string s2)
Put s1 to output
Put " and " to output
Put s2 to output
What is the total output when K("sign", "horse") is called 2 times?
Options:
sign and horse and sign and horse
sign and horsesign and horse
sign and horse
sign and horse
sign and horse sign and horse
Answer:
EExplanation:
Comprehensive and Detailed Explanation From Exact Extract:
The function K(s1, s2) outputs s1, followed by " and ", followed by s2. When called with K("sign", "horse"), it outputs "sign and horse". Calling it twice repeats this output. According to foundational programming principles, multiple function calls append their outputs in sequence unless specified otherwise (e.g., no newlines assumed unless explicit).
Single Call: K("sign", "horse") outputs "sign and horse".
Two Calls: The output is "sign and horse" followed by "sign and horse", resulting in "sign and horse sign and horse".
Option A: "sign and horse and sign and horse." This is incorrect. This suggests an extra "and" between the two outputs, which is not produced by the function.
Option B: "sign and horsesign and horse." This is incorrect. This implies no space between the two outputs, but typical output mechanisms (e.g., print in Python) may add spaces or newlines, and the space is explicit in the correct option.
Option C: "sign and horse." This is incorrect. This is the output of one call, not two.
Option D: "sign and horse." This is incorrect. Identical to C, it represents one call.
Option E: "sign and horse sign and horse." This is correct. It accurately represents the concatenated output of two calls: "sign and horse" twice.
Certiport Scripting and Programming Foundations Study Guide (Section on Functions and Output).
Python Documentation: “Print Function”
W3Schools: “C Output”
Which expression has a values equal to the rightmost digit of the integer q = 16222?
Options:
Q / 100000
10 % q
Q % 10
Q % 10000````````````````````
Answer:
CExplanation:
The modulus operator % is used to find the remainder of a division of two numbers. When you use q % 10, you are essentially dividing q by 10 and taking the remainder, which will always be the rightmost digit of q in base 10. This is because our number system is decimal (base 10), and any number modulo 10 will yield the last digit of that number. For example, 16222 % 10 will give 2, which is the rightmost digit of 16222.
What is a feature of CM as a programming language
Options:
The code must be compiled into machine code in the form of an executable file before execution.
The program usually runs slower than an interpreted language.
The code runs directly one statement at a time by another program called a compiler
The code does not require being translated into machine code but can be run by a separate program called a compiler.
Answer:
AExplanation:
The C(M) programming language is designed to translate mathematical constructions into efficient C programs. It is a declarative functional language with strong type checking and supports high-level functional programming. The C(M) compiler translates the C(M) program into a readable C program, which then needs to be compiled into machine code in the form of an executable file before it can be executed1. This process is typical of compiled languages, where the source code is transformed into machine code, which can be directly executed by the computer’s CPU. In contrast, interpreted languages are typically run by an interpreter, executing one statement at a time, which generally results in slower execution compared to compiled languages.
Which two statements describe advantages to using programming libraries?
Options:
Using a library minimizes copyright issues in coding
A program that uses libraries is more portable than one that does not.
Using libraries turns procedural code into object-oriented code.
Libraries always make code run faster.
The programmer can improve productivity by using libraries.
Using a library prevents a programmer from having to code common tasks by hand.
Answer:
E, FExplanation:
E. The programmer can improve productivity by using libraries.
Why: Libraries offer pre-written, tested code for common tasks. This saves developers time and effort, leading to increased productivity.
F. Using a library prevents a programmer from having to code common tasks by hand.
Why: The core purpose of libraries is to provide reusable code solutions. This eliminates the need to reinvent the wheel for frequently used functions and operations.
A software developer creates a list of all objects and functions that will be used in a board game application and then begins to write the code for each object. Which two phases of the Agile approach are being carried out?
Options:
Analysis and design
Design and implementation
Analysis and implementation
Design and testing
Answer:
BExplanation:
Comprehensive and Detailed Explanation From Exact Extract:
The tasks described involve creating a technical plan (listing objects and functions) and coding (writing the objects). According to foundational programming principles and Agile methodologies, these correspond to the design phase (planning the structure) and the implementation phase (coding).
Agile Phases Analysis:
Analysis: Defines requirements (e.g., “the game must support players and moves”).
Design: Specifies technical components (e.g., objects like Player, Board, and functions like makeMove()).
Implementation: Writes the code for the specified components.
Testing: Verifies the code works as intended.
Tasks Breakdown:
Creating a list of objects and functions: This is a design task, as it involves planning the program’s structure (e.g., class diagrams or function signatures).
Writing the code for each object: This is an implementation task, as it involves coding the objects (e.g., implementing the Player class).
Option A: "Analysis and design." This is incorrect. Analysis defines high-level requirements, not the specific objects and functions, which are part of design.
Option B: "Design and implementation." This is correct. Designing the list of objects and functions occurs in the design phase, and writing their code occurs in the implementation phase.
Option C: "Analysis and implementation." This is incorrect. Analysis does not involve listing technical components like objects and functions.
Option D: "Design and testing." This is incorrect. Testing verifies the coded objects, not the act of creating their list or writing their code.
Certiport Scripting and Programming Foundations Study Guide (Section on Agile Phases).
Sommerville, I., Software Engineering, 10th Edition (Chapter 4: Agile Software Development).
Agile Alliance: “Design and Implementation”
Which output results from the given algorithm?
Options:
1
5
10
60
Answer:
CExplanation:
The algorithm depicted in the image is a simple loop that iterates 5 times. Each iteration multiplies the current value of i by 2 and adds it to the variable sum. The loop starts with i equal to 1 and sum equal to 0. Here’s the breakdown:
First iteration: i = 1, sum = 0 + (1 * 2) = 2
Second iteration: i = 2, sum = 2 + (2 * 2) = 6
Third iteration: i = 3, sum = 6 + (3 * 2) = 12
Fourth iteration: i = 4, sum = 12 + (4 * 2) = 20
Fifth iteration: i = 5, sum = 20 + (5 * 2) = 30
However, the algorithm includes a condition that checks if sum is greater than 10. If this condition is true, the algorithm outputs the value of i and stops. This condition is met during the third iteration, where sum becomes 12. Therefore, the algorithm outputs the value of i at that point, which is 3.
A software developer creates a list of all objects and functions that will be used in a board game application and then begins to write the code for each object.
Options:
Analysis and implementation
Analysis and design
Design and implementation
Design and testing
Answer:
CExplanation:
The process described involves two main phases: first, the developer is designing the application by creating a list of all objects and functions (the design phase), and then they are writing the code for each object (the implementation phase). This aligns with option C, Design and Implementation. Analysis would involve understanding the requirements or problems the software will address, which is not mentioned in the scenario. Testing is a separate phase that typically occurs after implementation to ensure the code works as intended.
What does a function definition consist of?
Options:
The function's argument values
An invocation of a function's name
A list of all other functions that call the function
The function's name, inputs, outputs, and statements
Answer:
DExplanation:
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.
An example of an behavioral diagram is shown.
What is generally visualized with a behavioral diagram"?
Options:
Quality control mechanisms
Relative sizes of program components
Operating system compatibility
The dynamic flow of software
Answer:
DExplanation:
Behavioral diagrams are a key component in software engineering, particularly within the Unified Modeling Language (UML), which is used to model the dynamic aspects of systems. These diagrams help visualize the behavior of a system over time, including how it responds to various stimuli and the state changes it undergoes during its operation.
The types of behavioral diagrams include:
State Machine Diagrams: These show the state of a system or component at finite instances of time, focusing on state transitions in response to events.
Activity Diagrams: These illustrate the flow of control in a system, modeling both sequential and concurrent activities.
Use Case Diagrams: These depict the functionality of a system and its interaction with external agents.
Sequence Diagrams: These detail the interactions between objects in a sequential order, showing the order of operations.
Communication Diagrams: These show the sequenced messages exchanged between objects.
In the context of the provided image, a behavioral diagram would generally be used to visualize option D, the dynamic flow of software, as it captures the interactions, events, and states that occur within a system during its execution12345.
What does the following algorithm determine?
if x < 0
a = 1
else if x = 0
a = 2
else
a = 3
Options:
Whether x is odd
Whether x is evenly divisible by 2 or 3
Whether x is negative, 0, or positive
Whether x is even
Answer:
CExplanation:
Comprehensive and Detailed Explanation From Exact Extract:
The algorithm assigns a value to a based on the value of x, checking if x is negative, zero, or positive. According to foundational programming principles, conditional statements (if-else) are used to categorize inputs based on conditions.
Algorithm Analysis:
if x < 0: If x is negative, set a = 1.
else if x = 0: If x is zero, set a = 2. (Note: = is likely a typo for == in comparison.)
else: If x > 0 (positive), set a = 3.
Outcome: The algorithm categorizes x into three states: negative (x < 0), zero (x == 0), or positive (x > 0).
Option A: "Whether x is odd." Incorrect. The algorithm does not check parity (e.g., x % 2).
Option B: "Whether x is evenly divisible by 2 or 3." Incorrect. No divisibility checks (e.g., x % 2 or x % 3) are performed.
Option C: "Whether x is negative, 0, or positive." Correct. The conditions directly test x < \ 0, x == 0, and x > 0.
Option D: "Whether x is even." Incorrect. The algorithm does not test evenness.
Certiport Scripting and Programming Foundations Study Guide (Section on Conditional Statements).
Python Documentation: “If Statements”
W3Schools: “C If Else”
Which action occurs during the design phase of an Agile process?
Options:
Determining the functions that need to be written
Determining the goals of the project
Writing the required objects
Deciding on the name of the program
Answer:
AExplanation:
Comprehensive and Detailed Explanation From Exact Extract:
In Agile, the design phase focuses on creating technical specifications and plans for implementing the software, including identifying functions, classes, or modules. According to foundational programming principles, this phase bridges requirements (from analysis) to coding (in implementation).
Option A: "Determining the functions that need to be written." This is correct. During the design phase, the team specifies the functions, methods, or components (e.g., function signatures, class methods) required to meet the requirements. For example, designing a calculateTotal() function for an e-commerce system occurs here.
Option B: "Determining the goals of the project." This is incorrect. Project goals are established during the analysis phase, where requirements and user stories are defined.
Option C: "Writing the required objects." This is incorrect. Writing code (e.g., implementing classes or objects) occurs during the implementation phase, not design.
Option D: "Deciding on the name of the program." This is incorrect. Naming the program is a minor decision, typically made earlier (e.g., during project initiation or analysis), and is not a primary focus of the design phase.
Certiport Scripting and Programming Foundations Study Guide (Section on Agile Design Phase).
Agile Alliance: “Agile Design”
Fowler, M., Refactoring: Improving the Design of Existing Code (design principles in Agile).
A programming loam is using the waterfall design approach to create an application. Which deliverable would be produced during the design phase?
Options:
A report of customer satisfaction
A list of additional features to be added during revision
A written description of the goals for the project
The programming paradigm to be used
Answer:
CExplanation:
In the Waterfall model, a traditional software development lifecycle (SDLC) methodology, the design phase follows the requirements phase. During the design phase, the focus is on creating a detailed specification of the system to be developed. This includes:
Architectural Design: Outlining the overall structure of the system.
Interface Design: Defining how the software components will interact with each other and with users.
Component Level Design: Specifying the behavior of individual components.
Data Structure Design: Establishing how data is organized within the system.
The deliverable produced during this phase is a comprehensive design document that describes the architecture, components, interfaces, and data structures of the application in detail. It serves as a blueprint for the next phase of the Waterfall process, which is implementation (coding).
Which two situations would be helped by using a programming library?
Options:
A programmer needs to write several interacting objects for a student gradebook application, some of which need an inheritance structure.
A programming student is writing code to iterate through the integers in a list and determine the maximum.
A video game programmer needs to perform several animation tasks, all of which are very common in the industry. The programmer does not want to have to code each task. And they are unsure if they a even know how lo code a few of them.
A programmer needs to perform a series of file compression tasks. These tasks are commonly performed by programmers, and the programmer does not want to have to code them all by hand
A programmer is developing a database application that can house various types of data. The software cannot know ahead of time the data type, and so the programmer needs variables that do not require an initial declaration type.
A programmer is writing a piece of mathematical code that requires the heavy use of recursive functions.
Answer:
C, DExplanation:
Programming libraries are collections of pre-written code that programmers can use to perform common tasks without having to write the code from scratch. They are particularly helpful in situations where:
The tasks are common and standardized across the industry, such as animation tasks in video games (Option C). Using a library can save time and resources, and also ensure that the animations are up to industry standards.
The tasks are well-known and frequently performed by many programmers, such as file compression (Option D). Libraries provide a reliable and tested set of functions that can handle these tasks efficiently.
For the other options:
A: While a library could be used, writing interacting objects and implementing inheritance is a fundamental part of object-oriented programming and may not necessarily require a library.
B: Iterating through a list to find the maximum value is a basic programming task that typically doesn’t require a library.
E: Dynamic typing or the use of variables without an initial declaration type is a feature of the programming language itself rather than a library.
F: Recursive functions are a programming concept that can be implemented without the need for a library, unless the recursion is part of a specific algorithm that a library might provide.
Which two statement describe advantages to using programming libraries? Choose 2 answers
Options:
Using libraries turns procedural code into object-oriented code.
Using a library prevents a programmer from having to code common tasks by hand
A program that uses libraries is more portable than one that does not
Libraries always make code run faster.
The programmer can improve productivity by using libraries.
Using a library minimizes copyright issues in coding.
Answer:
B, EExplanation:
Programming libraries offer a collection of pre-written code that developers can use to perform common tasks, which saves time and effort. This is because:
B. Libraries provide pre-coded functions and procedures, which means programmers don’t need to write code from scratch for tasks that are common across many programs. This reuse of code enhances efficiency and reduces the potential for errors in coding those tasks.
E. By using libraries, programmers can significantly improve their productivity. Since they are not spending time writing and testing code for tasks that the library already provides, they can focus on the unique aspects of their own projects.
What is the Agile phase that results in a list of objects to be written?
Options:
Design
Testing
Implementation
Analysis
Answer:
AExplanation:
Comprehensive and Detailed Explanation From Exact Extract:
In Agile software development, the process is iterative and focuses on delivering working software incrementally. According to foundational programming principles and Agile methodologies (e.g., Certiport Scripting and Programming Foundations Study Guide, Agile Manifesto), the design phase involves creating detailed plans for the software, including identifying objects (e.g., classes in object-oriented programming) to be implemented.
Agile Phases Overview:
Analysis: Defines requirements and goals (e.g., user stories, project scope).
Design: Creates detailed plans, including system architecture, data models, and objects/classes to be written.
Implementation: Writes and integrates code for the designed components.
Testing: Verifies that the implemented code meets requirements.
Option A: "Design." This is correct. During the design phase in Agile, the team translates requirements into technical specifications, often producing a list of objects (e.g., classes, modules) to be coded. For example, in an object-oriented project, the design phase identifies classes like User, Order, or Product.
Option B: "Testing." This is incorrect. Testing verifies the implemented code, not the creation of a list of objects.
Option C: "Implementation." This is incorrect. Implementation involves writing the code for the objects identified during the design phase.
Option D: "Analysis." This is incorrect. Analysis focuses on gathering requirements and defining what the system should do, not specifying technical objects.
Certiport Scripting and Programming Foundations Study Guide (Section on Software Development Life Cycle: Agile).
Agile Manifesto: “Principles of Agile Development”
Sommerville, I., Software Engineering, 10th Edition (Chapter 4: Agile Software Development).
A program steps through an array and adds up all the numbers stored in the array. What is the appropriate individual control structure that should be used?
Options:
One while loop
Nested for loops
Multiple if statements
One for loop
Answer:
DExplanation:
Comprehensive and Detailed Explanation From Exact Extract:
To sum all numbers in an array, the program must iterate through each element exactly once and add it to a running total. According to foundational programming principles (e.g., Certiport Scripting and Programming Foundations Study Guide), a for loop is the most appropriate control structure for iterating over a known sequence like an array.
Task Analysis:
Input: An array of numbers (e.g., [1, 2, 3]).
Operation: Iterate through each element and add to a sum (e.g., 1 + 2 + 3 = 6).
A single loop is sufficient, as the task involves a single pass through the array.
Option A: "One while loop." This is incorrect. While a while loop can iterate through an array (e.g., using an index variable), it requires manual index management (e.g., i = 0; while i < length), making it less concise and more error-prone than a for loop for this task.
Option B: "Nested for loops." This is incorrect. Nested loops are used for multi-dimensional arrays or multiple iterations (e.g., matrix operations), but summing a single array requires only one loop.
Option C: "Multiple if statements." This is incorrect. If statements are for conditional logic, not iteration. They cannot traverse an array to sum elements.
Option D: "One for loop." This is correct. A for loop is ideal for iterating over an array’s elements. For example, in Python:
numbers = [1, 2, 3]
total = 0
for num in numbers:
total += num
Or in C:
c
int numbers[] = {1, 2, 3};
int total = 0;
for (int i = 0; i < 3; i++) {
total += numbers[i];
}
Certiport Scripting and Programming Foundations Study Guide (Section on Control Structures: Loops).
Python Documentation: “For Statements”
W3Schools: “C For Loop”
What is an argument?
Options:
A piece of information provided in a function call
A declared piece of information within a function
A piece of information assigned to a function's output
An input named in the definition of a function
Answer:
AExplanation:
In programming, an argument is a value that is passed to a function when it is called. The function can then use that information within its scope as it runs. Arguments are often used interchangeably with parameters, but they refer to the actual values provided to the function, while parameters are the variable names listed in the function’s definition that receive the argument values12.
For example, consider a function calculateSum that takes two arguments, a and b:
Python
def calculateSum(a, b):
return a + b
# Here, 5 and 3 are arguments provided in the function call.
result = calculateSum(5, 3)
AI-generated code. Review and use carefully. More info on FAQ.
In this case, 5 and 3 are the arguments provided in the function call to calculateSum. They are not declared within the function (option B), not assigned to the function’s output (option C), nor are they inputs named in the definition of the function (option D). Instead, they are pieces of information provided during the function call, which aligns with option A.
The steps in an algorithm to calculate the positive difference in given values, x and y, are given in no particular order:
Put Diff to output.
Set Diff = x - y.
If y > x, set Diff = y - x.
Declare variable Diff.What is the first step of the algorithm?
Options:
Put Diff to output.
Set Diff = x - y.
If y > x, set Diff = y - x.
Declare variable Diff.
Answer:
DExplanation:
Comprehensive and Detailed Explanation From Exact Extract:
The algorithm calculates the positive difference between x and y (i.e., |x - y|). According to foundational programming principles, an algorithm’s steps must be executed in a logical order, and variables must be declared before they are used.
Steps Analysis:
Declare variable Diff: Creates the variable Diff to store the result. Must occur first, as other steps use Diff.
Set Diff = x - y: Computes the difference, assuming x >= y. Requires Diff to exist.
If y > x, set Diff = y - x: Adjusts Diff to ensure it’s positive if y > x. Requires Diff to exist.
Put Diff to output: Outputs the final result. Must occur last, after Diff is computed.
Logical Order:
Declare Diff (create variable).
Set Diff = x - y (initial difference).
If y > x, set Diff = y - x (ensure positive).
Output Diff.
Option A: "Put Diff to output." Incorrect. Outputting Diff requires it to be computed, which happens after declaration and calculation.
Option B: "Set Diff = x - y." Incorrect. Setting Diff requires Diff to be declared first.
Option C: "If y > x, set Diff = y - x." Incorrect. This step uses Diff, so declaration must precede it.
Option D: "Declare variable Diff." Correct. Declaring Diff is the first step, as all other steps depend on Diff existing.
Certiport Scripting and Programming Foundations Study Guide (Section on Algorithms and Variables).
Python Documentation: “Variable Declaration”
W3Schools: “C Variables”
What is one task that could be accomplished using a while loop?
Options:
When the user inputs a number, the program outputs "True" when the number is a multiple of 10.
The user inputs an integer, and the program prints out whether the number is even or odd and whether the number is positive, negative, or zero.
After inputting two numbers, the program prints out the larger of the two.
A user is asked to enter a password repeatedly until either a correct password is entered or five attempts have been made.
Answer:
DExplanation:
Comprehensive and Detailed Explanation From Exact Extract:
A while loop repeatedly executes a block of code as long as a condition is true, making it suitable for tasks requiring iteration until a condition changes. According to foundational programming principles, while loops are ideal for scenarios with an unknown number of iterations or conditional repetition.
Option A: "When the user inputs a number, the program outputs 'True' when the number is a multiple of 10." This is incorrect. This task requires a single check (number % 10 == 0), which can be done with an if statement, not a loop.
Option B: "The user inputs an integer, and the program prints out whether the number is even or odd and whether the number is positive, negative, or zero." This is incorrect. This task involves a single input and multiple conditional checks, handled by if statements, not a loop.
Option C: "After inputting two numbers, the program prints out the larger of the two." This is incorrect. Comparing two numbers requires a single if statement (e.g., if (a > b)), not a loop.
Option D: "A user is asked to enter a password repeatedly until either a correct password is entered or five attempts have been made." This is correct. This task requires repeated input until a condition is met (correct password or five attempts), which is ideal for a while loop. For example, in Python:
attempts = 0
while attempts < 5 and input("Password: ") != "correct":
attempts += 1
Certiport Scripting and Programming Foundations Study Guide (Section on Control Structures: Loops).
Python Documentation: “While Statements”
W3Schools: “C While Loop”
A program adds a service fee to the total cost of concert tickets when the tickets are printed and mailed to customers. Another service fee is also added if the
Options:
Multiple if statements
If statement
While loop
Do-while loop
Answer:
AExplanation:
The scenario describes conditional logic where service fees depend on these factors:
Printing: There seems to be a base service fee whenever tickets are printed.
Mailing: An additional fee applies if tickets are printed and mailed.
The most suitable way to model this logic is using multiple if statements:
First if: Checks if tickets are printed. If so, add the base printing fee.
Second if (nested): Checks if tickets are mailed (and by implication, already printed). If so, add the mailing fee.
What is a string?
Options:
A built-in method
A very precise sequence of steps
A sequence of characters
A name that refers to a value
Answer:
CExplanation:
In the context of programming, a string is traditionally understood as a sequence of characters. It can include letters, digits, symbols, and spaces, and is typically enclosed in quotation marks within the source code. For instance, “Hello, World!” is a string. Strings are used to store and manipulate text-based information, such as user input, messages, and textual data within a program. They are one of the fundamental data types in programming and are essential for building software that interacts with users or handles textual content.
Which phase of a waterfall approach defines specifies on how to build a program?
Options:
Analysis
Implementation
Design
Testing
Answer:
CExplanation:
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.
Which type of language requires variables to be declared ahead of time and prohibits their types from changing while the program runs?
Options:
Scripted (interpreted)
Procedural
Static
Compiled
Answer:
CExplanation:
The type of language that requires variables to be declared ahead of time and prohibits their types from changing while the program runs is known as a statically typed language. In statically typed languages, the type of a variable is determined at compile-time and cannot be changed during runtime. This means that the compiler must know the exact data types of all variables used in the program, and these types must remain consistent throughout the execution of the program. Statically typed languages require developers to declare the type of each variable before using it, which can help catch type errors during the compilation process, potentially preventing runtime errors and bugs.
Given integer x = 12 and integer y = 4
What is the value of the expression x + y12?
Options:
6
8
14
Answer:
CExplanation:
The expression given is ( x + y^{12} ), with ( x = 12 ) and ( y = 4 ). To evaluate this expression, we substitute the values of ( x ) and ( y ) into the expression:
( x + y^{12} = 12 + 4^{12} )
Since ( 4^{12} ) is a very large number, the significant value in this expression comes from ( 4^{12} ), and the addition of 12 does not change the order of magnitude of the result. Therefore, the value of ( x + y^{12} ) is much greater than the options provided (A. 6, B. 8, C. 14). It seems there might be a typo in the expression or the options provided. If the expression was meant to be ( x + y \times 12 ), then the answer would be:
( x + y \times 12 = 12 + 4 \times 12 = 12 + 48 = 60 )
However, since this option is not available, and based on the provided options, the closest correct answer, assuming the expression is ( x + y ), would be:
( x + y = 12 + 4 = 16 )
But since 16 is not an option, and without further context, the best match from the given options would be C. 14, even though it is not the exact answer.
Which expression has a value equal to the rightmost digit of the integer q = 7777?
Options:
10 % q
q % 10
q / 10000
q % 10000
Answer:
BExplanation:
Comprehensive and Detailed Explanation From Exact Extract:
To find the rightmost digit of an integer q = 7777, we need the units digit (i.e., 7). According to foundational programming principles, the modulo operator (%) with 10 isolates the rightmost digit of a number.
Option A: "10 % q."
Compute: 10 % 7777 = 10 (since 10 ÷ 7777 has a remainder of 10).
Result: 10 ≠ 7. Incorrect.
Option B: "q % 10."
Compute: 7777 % 10 = 7 (remainder of 7777 ÷ 10, isolating the units digit).
Result: 7 = rightmost digit. Correct.
Option C: "q / 10000."
Compute: 7777 / 10000 = 0.7777 (floating-point division).
Result: 0.7777 ≠ 7. Incorrect.
Option D: "q % 10000."
Compute: 7777 % 10000 = 7777 (since 7777 < 10000).
Result: 7777 ≠ 7. Incorrect.
Certiport Scripting and Programming Foundations Study Guide (Section on Modulo Operator).
C Programming Language Standard (ISO/IEC 9899:2011, Section on Multiplicative Operators).
W3Schools: “Python Operators”
What is put to output by the following flowchart, if the input is 3.5?
Options:
Backlog
Interview
Return
interviewBacking
Answer:
BExplanation:
The flowchart provided in the image represents a decision-making process based on the input value. Given the input of 305, we follow the flowchart’s decision paths. The first decision checks if the input is less than 200, which 305 is not, so we move to the next decision point. The second decision asks if the input is greater than 300. Since 305 is greater than 300, we follow the path for ‘yes’ which leads us to the output “Interview”. Therefore, the correct output for the input 305 according to the flowchart is “Interview”.
Which expression evaluates to 14 if integer y = 13?
Options:
11 + y % 5
11 - y / 5.0
(11 + y) % 5
11.0 - y / 5
Answer:
AExplanation:
To find an expression that evaluates to 14 when y = 13, let’s evaluate each option:
A. 11 + y % 5: The modulo operation (%) gives the remainder after division. For y = 13, 13 % 5 equals 3. Adding 11 to 3 results in 14, so this expression is correct.
B. 11 - y / 5.0: Dividing 13 by 5.0 gives 2.6. Subtracting 2.6 from 11 does not yield 14, so this expression is incorrect.
C. (11 + y) % 5: Adding 11 to 13 results in 24. Taking the modulo of 24 with 5 gives 4, which is not equal to 14. Therefore, this expression is incorrect.
D. 11.0 - y / 5: Dividing 13 by 5 gives 2.6. Subtracting 2.6 from 11.0 does not yield 14, so this expression is incorrect.
The correct expression is A. 11 + y % 5.
An algorithm should output "OK" if a number is between 98.3 and 98.9, else the output is "Not OK." Which test is a valid test of the algorithm?
Options:
Input 98.6. Ensure output is "Not OK."
Input 98.6. Ensure output is "OK."
Input 99.9. Ensure output is "OK."
Input 99.9. Ensure output is "98.9."
Answer:
BExplanation:
Comprehensive and Detailed Explanation From Exact Extract:
A valid test checks if the algorithm produces the expected output for a given input, according to its specification. The algorithm outputs "OK" for numbers in the range [98.3, 98.9] (inclusive or exclusive bounds not specified, but typically inclusive in such problems) and "Not OK" otherwise. According to foundational programming principles, we evaluate each test case.
Specification:
Input in [98.3, 98.9] → Output: "OK".
Input outside [98.3, 98.9] → Output: "Not OK".
Option A: "Input 98.6. Ensure output is 'Not OK.'" Incorrect. Since 98.6 is between 98.3 and 98.9 (98.3 ≤ 98.6 ≤ 98.9), the output should be "OK", not "Not OK". This test is invalid.
Option B: "Input 98.6. Ensure output is 'OK.'" Correct. 98.6 is within the range, and the expected output is "OK", making this a valid test.
Option C: "Input 99.9. Ensure output is 'OK.'" Incorrect. 99.9 is outside the range (99.9 > 98.9), so the output should be "Not OK", not "OK". This test is invalid.
Option D: "Input 99.9. Ensure output is '98.9.'" Incorrect. The algorithm outputs either "OK" or "Not OK", not a numerical value like "98.9". This test is invalid.
Certiport Scripting and Programming Foundations Study Guide (Section on Algorithm Testing).
General Programming Principles: Testing and Validation.
W3Schools: “Python Conditions”
Which line is a loop variable update statement in the sample code?
Options:
integer h = 0
h = h +1
(userInput !=pwd) and (h <= 10)
if userInput == pwd
Answer:
BExplanation:
In programming, a loop variable update statement is used to modify the loop variable’s value with each iteration of the loop. This is crucial for the progression and eventual termination of the loop. The statement h = h + 1 is a classic example of a loop variable update statement. It increments the value of h by 1, ensuring that the loop can move towards its completion condition. Without such an update, the loop could potentially continue indefinitely, leading to an infinite loop.
A particular sorting takes integer list 10,8 and incorrectly sorts the list to 6, 10, 8.
What is true about the algorithm’s correctness for sorting an arbitrary list of three integers?
Options:
The algorithm only works for 10,6, 8
The algorithm is correct
The algorithm's correctness is unknown
The algorithm is incorrect
Answer:
DExplanation:
The correctness of a sorting algorithm is determined by its ability to sort a list of elements into a specified order, typically non-decreasing or non-increasing order. For an algorithm to be considered correct, it must consistently produce the correct output for all possible inputs. In the case of the given algorithm, it takes the input list [10, 8] and produces the output [6, 10, 8], which is not sorted in non-decreasing order. This indicates that the algorithm does not correctly sort the list, as the output is neither sorted nor does it maintain the integrity of the original list (the number 6 was not in the original list).
Furthermore, the fact that the output contains an integer (6) that was not present in the input list suggests that the algorithm is not preserving the elements of the input list, which is a fundamental requirement for a sorting algorithm. This violation confirms that the algorithm is incorrect for sorting an arbitrary list of three integers, as it cannot be relied upon to sort correctly or maintain the original list elements.
Which phase of an Agile approach would create a function that calculates shipping costs based on an item’s weight and delivery zip code?
Options:
Testing
Analysis
Implementation
Design
Answer:
CExplanation:
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”
Sommerville, I., Software Engineering, 10th Edition (Chapter 4: Agile Software Development).
It is given that integer x = 41 and integer y = 16. What is the value of the expression (x % y)?
Options:
-15
-11
-8
9
Answer:
DExplanation:
Comprehensive and Detailed Explanation From Exact Extract:
The modulo operator (%) returns the remainder when the first operand is divided by the second. According to foundational programming principles (e.g., C and Python standards), for integers x and y, x % y computes the remainder of x ÷ y.
Given: x = 41, y = 16.
Compute: 41 ÷ 16 = 2 (quotient, ignoring decimal) with a remainder.
16 × 2 = 32, and 41 - 32 = 9. Thus, 41 % 16 = 9.
Option A: "-15." This is incorrect. The modulo operation with positive integers yields a non-negative result.
Option B: "-11." This is incorrect. The result is positive and based on the remainder.
Option C: "-8." This is incorrect. The remainder cannot be negative here.
Option D: "9." This is correct, as calculated above.
Certiport Scripting and Programming Foundations Study Guide (Section on Operators).
C Programming Language Standard (ISO/IEC 9899:2011, Section on Multiplicative Operators).
Python Documentation: “Modulo Operator”
What is the outcome for the given algorithm? Round to the nearest tenth, if necessary.
Options:
5.0
6.0
6.1
8.4
Answer:
AExplanation:
Initialize two variables: x and Count to zero.
Iterate through each number in the NumList.
For each number in the list:
Add the number to x.
Increment Count by one.
After processing all numbers in the list, calculate the average:
Average = x / Count.
The NumList contains 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.
Which kind of language is HTML?
Options:
Dynamically typed
Markup
Statically typed
Object-oriented
Answer:
BExplanation:
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”
Mozilla Developer Network: “HTML Basics”
Scripting-and-Programming-Foundations Free PDF Answers
Total 138 questions
Unlock Scripting-and-Programming-Foundations Features
- Scripting-and-Programming-Foundations All Real Exam Questions
- Scripting-and-Programming-Foundations Exam easy to use and print PDF format
- Download Free Scripting-and-Programming-Foundations Demo (Try before Buy)
- Free Frequent Updates
- 100% Passing Guarantee by DumpsWrap
Questions & Answers PDF Demo
- Scripting-and-Programming-Foundations All Real Exam Questions
- Scripting-and-Programming-Foundations Exam easy to use and print PDF format
- Download Free Scripting-and-Programming-Foundations Demo (Try before Buy)
- Free Frequent Updates
- 100% Passing Guarantee by DumpsWrap
Practice Tesitng Engine Demo
Dumpswrap Footer Menu
DumpsWrap All Rights Reserved
Copyright © 2014-2025 DumpsWrap. All Rights Reserved
