Partial preview of the text
Download WGU D278 SCRIPTING AND PROGRAMMING FOUNDATIONS: OA EXAM PREP & STUDY GUIDE and more Exams Programming Languages in PDF only on Docsity!
WGU D278 SCRIPTING AND PROGRAMMING PRE - ASSESSMENT LATEST 2026 ACTUAL EXAM| COMPLETE 250 REAL EXAM QUESTIONS AND CORRECT DETAILED ANSWERS (VERIFIED ANSWERS) ALREADY GRADED A+ (BRAND NEW!) 1. What is a program in the context of computer science? A) A collection of hardware components B) A set of instructions executing one at a time C) A type of computer memory D) A network protocol Answer: B) A set of instructions executing one at a time Rationale: A program consists of instructions that execute sequentially, one at a time. It represents the fundamental building block of software development and is distinguished from hardware components, memory, or protocols . 2. Which of the following correctly describes the input- process-output model? A) Input stores data, process retrieves data, output displays data B) A program gets data (input), performs computations (process), and puts data somewhere (output) C) Output is received, processed, and then input is generated D) The model only applies to hardware systems Answer: B) A program gets data (input), performs computations (process), and puts data somewhere (output) Rationale: The input-process-output model defines the three core operations of a program: obtaining data from sources like a file or keyboard, performing computations on that data, and placing the processed data somewhere such as a file or screen. C) A hardware component of a computer D) A debugging technique Answer: B) A sequence of instructions that solves a problem Rationale: An algorithm is a well-defined sequence of instructions that, when executed, solves a particular problem. It is the core of programming and is independent of any specific programming language . 5. What is a statement in programming? A) A comment added to code for human reading B) An instruction that carries out an action and executes one at a time C) A type of data storage D) A programming language feature Answer: B) An instruction that carries out an action and executes one at a time Rationale: A statement is the basic unit of execution in a program. Each statement performs a specific action, and statements are executed sequentially . 6. Which term refers to text within double quotes, such as "Hello, World!"? A) Variable B) Comment C) String literal D) Integer Answer: C) String literal 8. What does the newline character \n do in a program's output? A) Deletes the previous line B) Moves the cursor to the next output line C) Adds a space between words D) Repeats the previous output Answer: B) Moves the cursor to the next output line Rationale: The newline character \n causes the cursor to move to the beginning of the next output line. It exists invisibly in the output but affects where text is displayed . 9. What is a comment in programming? A) Code that executes repeatedly B) Text added to a program for human understanding, ignored by the program C) A variable that stores comments D) A type of loop Answer: B) Text added to a program for human understanding, ignored by the program Rationale: Comments are explanatory text included in source code for programmers to read and understand the code. They are completely ignored by the compiler or interpreter during execution 10. In programming, what does "whitespace" refer to? A) Only spaces between words B) Blank spaces, tab characters, and newlines that improve readability C) Characters that are white on screen D) Comments in code Rationale: Pseudocode is a simplified representation of an algorithm that uses language resembling a programming language but is easier for humans to understand. It is not meant to be executed . 12. Which of the following demonstrates incremental development? A) Writing the entire program before testing anything B) Writing, compiling, and testing a small amount of code, then repeating C) Developing only the user interface first D) Skipping testing until the end Answer: B) Writing, compiling, and testing a small amount of code, then repeating Rationale: Incremental development involves writing, compiling, and testing small pieces of code, then gradually adding more 10 functionality. This approach helps catch errors early and makes development more manageable . 13. What is a variable in programming? A) A value that never changes B) Anamed memory location that can store data that may change during program execution C) A type of function D) A programming language Answer: B) A named memory location that can store data that may change during program execution Rationale: A variable is a named storage location in memory whose value can be changed during program execution. It holds data that the program can reference and manipulate . 11 Answer: B) Assignment of a left-side variable with a right- side value Rationale: In programming, the = operator is used for assignment, storing the value of the right-side expression into the left-side variable. It does not represent mathematical equality . 16. What is an expression in programming? A) A combination of variables, values, and operators that evaluates to a single result B) A statement that controls program flow C) A function definition D) A type of comment Answer: A) A combination of variables, values, and operators that evaluates to a single result 13 Rationale: An expression is any valid combination of variables, literals, and operators that computes and returns a single value . 17. What is a floating-point number? A) A number that can only be positive B) A real number with a fractional part, like 98.6 or -666.667 C) A number represented without decimals D) An imaginary number Answer: B) A real number with a fractional part, like 98.6 or - 666.667 Rationale: Floating-point numbers represent real numbers with a fractional component. They are used when values require decimal precision . 18. What is type conversion in programming? 14 Answer: B) A conversion automatically performed by the program Rationale: Implicit conversion is automatically performed by the language without the programmer's explicit instruction. For example, when adding an integer and a float, the integer may be implicitly converted to a float . 20. What is a type cast? A) A comment that describes a variable's type B) An explicit conversion of a value from one type to another C) A function that creates new types D) A type of variable declaration Answer: B) An explicit conversion of a value from one type to another 16 Rationale: A type cast is an explicit operation that converts a value from one data type to another. It is written by the programmer to specifically request the conversion . 21. Which data type should be used to store whether a user is logged in? A) Integer B) Float C) String D) Boolean Answer: D) Boolean Rationale: Boolean data types have only two possible values: true or false. They are ideal for storing binary states such as login status 17 C) A collection of related data D) A function that returns a value Answer: B) A variable that stores a single value Rationale: A scalar variable holds a single data item, such as a single integer, float, string, or boolean value. Arrays are non- scalar (aggregate) variables . 24. What is an array? A) A single variable that holds one value B) An ordered list of items of a given data type C) A variable that holds a decimal number D) A type of function Answer: B) An ordered list of items of a given data type 19 Rationale: An array is a data structure that stores multiple items in a single variable. The items are accessed using indices and are of the same data type . 25. What is the starting index of an array in most programming languages? A) 0 B) 1 C) -1 D) Depends on the language Answer: A) 0 Rationale: In most programming languages, array indexing starts at 0. The first element is at index 0, the second at index 1, and so on. 20