Launch offer: $20 off your order with code

Scripting-and-Programming-Foundations Practice questions

WGU Scripting and Programming Foundations Exam

0/5 checked

free questions
5
with answers
in the full set
138
question types
3

Updated

  1. Question 1

    Single answer

    What would a string be used to store?

    Choose one answer
    Show answer

    Correct answer

    • B

      The word "positive"

    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.

  2. Question 2

    Multiple answer

    What are two examples of valid function calls?

    Choose 2 answers.

    Choose 2 answers
    Show answer

    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).

  3. Question 3

    Hotspot

    Oder the tasks needed to safely replace a lamp's light bulb from first (1) to last (4).

    Select your answer from the pull down list.

    Exhibit
    Show answer

    Correct answer

    Answer
  4. Getting the hang of it? 133 more Scripting-and-Programming-Foundations questions to go, each with its answer. Unlock them all

  5. Question 4

    Single answer

    What is one characteristic of an object-oriented language that is not a characteristic of a procedural or functional language?

    Choose one answer
    Show answer

    Correct answer

    • C

      The language supports decomposing a program into objects that interact with one another.

    Explanation

    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.

  6. Question 5

    Single answer

    What is one task that could be accomplished using a while loop?

    Choose one answer
    Show answer

    Correct answer

    • D

      A user is asked to enter a password repeatedly until either a correct password is entered or five attempts have been made.

    Explanation

    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” (https://docs.python.org/3/reference/compound_stmts.html#while).

    W3Schools: “C While Loop” (https://www.w3schools.com/c/c_while_loop.php).

  7. Question 6 Locked Unlock to see this question
  8. Question 7 Locked Unlock to see this question

133 questions locked

Unlock all 138 Scripting-and-Programming-Foundations questions

You’ve had 5 for free. The other 133 work just like them: pick an answer, then check it.

Questions
138, each with its answer
Explanations
99% of questions explained
Formats
Single answer, Multiple answer, Hotspot
Version
11.1
Access
3 months from purchase

One-time payment

$49.00

Secure checkout