Docsity

CS 120 Computational Thinking module 4, Exams of Computer Science

Toggle sidebar
bg1
CS 120 Computational Thinking module 4
1. Which of the following best describes the primary focus of Module 4 in
computational thinking?
A) Understanding the history of computer science
B) Focusing on abstraction and problem-solving with core programming concepts
C) Learning about networking and cybersecurity
D) Mastering hardware components and their functions
Correct Answer: Focusing on abstraction and problem-solving with core
programming concepts
Rationale: Module 4 centers on abstraction—the process of filtering out irrelevant
details to focus on essential features—and applies it through problem-solving with
core programming concepts like variables, data types, and control structures. The
other options describe topics covered in other modules or courses.
2. What is the primary purpose of abstraction in computational thinking?
A) To store data permanently on a hard drive
B) To simplify complex problems by focusing on essential details
C) To increase the processing speed of a computer
D) To create physical models of computer systems
Correct Answer: To simplify complex problems by focusing on essential details
Rationale: Abstraction is a core computational thinking skill that reduces complexity
by hiding unnecessary details and emphasizing what matters most for solving a
problem. It does not involve storage, hardware speed, or physical modeling.
3. Which term refers to a named storage location in memory that holds a value
which can change during program execution?
A) Constant
B) Variable
C) Function
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29

Partial preview of the text

Download CS 120 Computational Thinking module 4 and more Exams Computer Science in PDF only on Docsity!

CS 120 Computational Thinking module 4

  1. Which of the following best describes the primary focus of Module 4 in computational thinking? A) Understanding the history of computer science B) Focusing on abstraction and problem-solving with core programming concepts C) Learning about networking and cybersecurity D) Mastering hardware components and their functions Correct Answer: Focusing on abstraction and problem-solving with core programming concepts Rationale: Module 4 centers on abstraction—the process of filtering out irrelevant details to focus on essential features—and applies it through problem-solving with core programming concepts like variables, data types, and control structures. The other options describe topics covered in other modules or courses.
  2. What is the primary purpose of abstraction in computational thinking? A) To store data permanently on a hard drive B) To simplify complex problems by focusing on essential details C) To increase the processing speed of a computer D) To create physical models of computer systems Correct Answer: To simplify complex problems by focusing on essential details Rationale: Abstraction is a core computational thinking skill that reduces complexity by hiding unnecessary details and emphasizing what matters most for solving a problem. It does not involve storage, hardware speed, or physical modeling.
  3. Which term refers to a named storage location in memory that holds a value which can change during program execution? A) Constant B) Variable C) Function

D) Loop Correct Answer: Variable Rationale: A variable is a named storage location whose value can change during program execution. A constant holds a fixed value, a function is a reusable block of code, and a loop is a control structure that repeats instructions.

  1. According to the module, what is the primary role of abstraction in designing a login form? A) To display all possible error messages simultaneously B) To focus on essential fields like username and password while hiding irrelevant details C) To encrypt the user's password before transmission D) To store all user data in a single table Correct Answer: To focus on essential fields like username and password while hiding irrelevant details Rationale: Abstraction in user interface design means presenting only what the user needs—such as username and password fields—while hiding complex backend processes. Encryption and data storage are separate concerns, and showing all errors at once would violate abstraction principles.
  2. What is the most likely outcome if a variable is declared but not initialized in most programming languages? A) The variable will automatically store a zero value B) The variable may contain unpredictable or garbage data C) The program will not compile D) The variable will be permanently deleted Correct Answer: The variable may contain unpredictable or garbage data

A) Integer B) Boolean C) Floating-point D) String Correct Answer: Floating-point Rationale: A GPA typically includes a decimal component (e.g., 3.75), so a floating- point data type is appropriate. Integers store whole numbers, Booleans store true/false, and strings store text.

  1. What is the primary purpose of a data type in programming? A) To specify the operations that can be performed on a value and how it is stored B) To determine the color of text in a user interface C) To define the speed at which a program runs D) To connect a program to a database Correct Answer: To specify the operations that can be performed on a value and how it is stored Rationale: A data type defines the kind of value a variable can hold (e.g., integer, float, string, Boolean) and determines what operations are valid. It is unrelated to UI colors, program speed, or database connections.
  2. According to the module, which of the following is an example of abstraction in everyday life? A) Using a map that shows only major roads and cities B) Following a recipe step by step C) Sorting a list of names alphabetically D) Repeating a task until it is complete Correct Answer: Using a map that shows only major roads and cities

Rationale: A map that shows only major roads and cities abstracts away minor streets and unnecessary details, making navigation easier. Following a recipe is an algorithm, sorting is an algorithm, and repeating a task is iteration.

  1. What is the most likely benefit of using abstraction when writing a program to calculate employee salaries? A) The program will run faster on all computers B) The program can focus on essential salary calculation logic without unnecessary details C) The program will automatically detect all errors D) The program will not require any input data Correct Answer: The program can focus on essential salary calculation logic without unnecessary details Rationale: Abstraction allows programmers to focus on the core logic of salary calculation (e.g., base pay, overtime, deductions) without being distracted by irrelevant implementation details. It does not guarantee speed, error detection, or eliminate input requirements.
  2. Which of the following is a valid variable name in most programming languages? A) 2ndScore B) total_score C) class D) my-score Correct Answer: total_score Rationale: Variable names typically must start with a letter or underscore and contain only letters, digits, and underscores. "2ndScore" starts with a digit, "class" is a reserved keyword, and "my-score" contains a hyphen. "total_score" follows common naming conventions.

Correct Answer: Abstraction simplifies problems by focusing on essential features Rationale: Abstraction is a problem-solving technique that reduces complexity by concentrating on the most important aspects of a problem. It does not make problems harder, eliminate algorithms, or apply only to hardware.

  1. What is the most likely outcome of using an uninitialized variable in a calculation? A) The program will always produce the correct result B) The calculation may produce an incorrect or unpredictable result C) The program will automatically initialize the variable to zero D) The variable will be ignored in the calculation Correct Answer: The calculation may produce an incorrect or unpredictable result Rationale: Using an uninitialized variable means its value is unknown (garbage), so any calculation involving it will likely produce incorrect or unpredictable results. The program does not automatically initialize variables to zero in all languages.
  2. Which of the following is an example of a Boolean data type? A) 42 B) 3. C) true D) "Hello" Correct Answer: true Rationale: A Boolean data type holds one of two values: true or false. The values 42 and 3.14 are numeric, and "Hello" is a string. Booleans are used in conditional expressions and logic.
  3. In the context of programming, what is a string?

A) A sequence of characters enclosed in quotation marks B) A numeric value with a decimal point C) A true or false value D) A type of loop Correct Answer: A sequence of characters enclosed in quotation marks Rationale: A string is a data type that represents text—a sequence of characters (letters, digits, symbols) enclosed in quotation marks. Numeric values, Booleans, and loops are different concepts.

  1. What is the primary purpose of using meaningful variable names? A) To make the program run faster B) To improve code readability and maintainability C) To reduce the amount of memory used D) To prevent syntax errors Correct Answer: To improve code readability and maintainability Rationale: Meaningful variable names (e.g., studentScore instead of x) make code easier to understand, debug, and maintain. They do not affect execution speed, memory usage, or prevent syntax errors.
  2. According to the module, which of the following is a key benefit of abstraction in software development? A) It allows programmers to manage complexity by hiding unnecessary details B) It guarantees that software will be free of bugs C) It eliminates the need for testing D) It automatically generates code Correct Answer: It allows programmers to manage complexity by hiding unnecessary details
  1. What is the primary purpose of a comment in source code? A) To explain the code and improve readability for humans B) To execute a specific operation C) To declare a variable D) To control the flow of the program Correct Answer: To explain the code and improve readability for humans Rationale: Comments are non-executable notes that document code, making it easier for programmers to understand and maintain. They do not perform operations, declare variables, or control flow.
  2. In the context of abstraction, what does "modeling" refer to? A) Creating a simplified representation of a real-world system to understand or predict its behavior B) Writing code in a specific programming language C) Testing a program for errors D) Installing software on a computer Correct Answer: Creating a simplified representation of a real-world system to understand or predict its behavior Rationale: Modeling is an abstraction technique that creates simplified representations of complex systems to facilitate understanding, prediction, and problem-solving. It is not limited to coding, testing, or installation.
  3. Which of the following is an example of procedural abstraction? A) Using a function to perform a specific task without knowing its internal implementation B) Storing data in a list C) Writing a loop to repeat a block of code D) Declaring a variable with a specific data type

Correct Answer: Using a function to perform a specific task without knowing its internal implementation Rationale: Procedural abstraction allows programmers to use functions as "black boxes"—they know what the function does but not necessarily how it does it. Storing data, writing loops, and declaring variables are separate concepts.

  1. What is the most likely benefit of using functions in a program? A) They promote code reuse and make programs easier to maintain B) They make the program longer and more complex C) They eliminate the need for variables D) They automatically fix all syntax errors Correct Answer: They promote code reuse and make programs easier to maintain Rationale: Functions encapsulate logic that can be called multiple times, reducing repetition and improving organization. They do not make programs longer, eliminate variables, or fix syntax errors.
  2. According to the module, which of the following best describes a variable's scope? A) The region of a program where the variable is accessible B) The speed at which the variable can be accessed C) The amount of memory the variable occupies D) The data type of the variable Correct Answer: The region of a program where the variable is accessible Rationale: Scope defines where in a program a variable can be accessed. Local variables are accessible only within their defining block, while global variables have broader scope. It is not about speed, memory, or data type.

Correct Answer: An error may occur if the program attempts to modify the constant's value Rationale: Constants cannot be modified. If a program tries to assign a new value to a constant, an error will occur (depending on the language, either at compile time or runtime). Constants do not automatically become variables.

  1. Which of the following best describes the relationship between abstraction and decomposition? A) They are the same thing B) Abstraction simplifies by hiding details, while decomposition breaks problems into smaller parts C) Abstraction is only used in hardware, while decomposition is only used in software D) Decomposition eliminates the need for abstraction Correct Answer: Abstraction simplifies by hiding details, while decomposition breaks problems into smaller parts Rationale: Abstraction and decomposition are complementary computational thinking skills. Abstraction filters out irrelevant details, while decomposition divides a problem into manageable sub-problems. They are not the same, not domain- specific, and do not eliminate each other.
  2. What is the primary purpose of pseudocode? A) To execute a program directly on a computer B) To describe an algorithm in a human-readable, code-like format without strict syntax C) To store data permanently D) To encrypt source code Correct Answer: To describe an algorithm in a human-readable, code-like format without strict syntax

Rationale: Pseudocode allows programmers to plan and communicate algorithms using plain language and structural conventions without worrying about the syntax of a specific programming language. It is not executable, does not store data, and does not encrypt code.

  1. In the context of programming, what is an expression? A) A combination of values, variables, and operators that produces a result B) A named storage location C) A control structure that repeats code D) A comment in the source code Correct Answer: A combination of values, variables, and operators that produces a result Rationale: An expression is a construct that evaluates to a value, such as x + 5 or a > b. Variables, loops, and comments are different concepts. Expressions are fundamental to calculations and conditions.
  2. Which of the following is an example of a relational operator? A) + B) = C) < D) AND Correct Answer: < Rationale: The less-than symbol (<) is a relational operator used to compare two values, returning a Boolean result. The plus sign is arithmetic, the equals sign is assignment, and AND is a logical operator.
  3. What is the most likely outcome of the expression 10 % 3? A) 0 B) 1
  1. What is the primary purpose of a function's return statement? A) To send a value back to the caller and exit the function B) To print a message to the console C) To declare a new variable D) To start an infinite loop Correct Answer: To send a value back to the caller and exit the function Rationale: The return statement ends the function's execution and optionally passes a value back to the code that called it. Printing, variable declaration, and loops are separate operations.
  2. In the context of programming, what is an argument? A) A value passed into a function when it is called B) A variable listed in a function definition C) The result returned by a function D) A type of loop Correct Answer: A value passed into a function when it is called Rationale: An argument is a value passed into a function when it is called. A parameter is a variable listed in a function definition that receives the argument value. The return value is the result, and a loop is a control structure.
  3. Which of the following best describes the relationship between a parameter and an argument? A) A parameter is a variable in a function definition; an argument is the value passed to it B) A parameter is the value passed; an argument is the variable C) They are exactly the same thing D) A parameter is a type of loop; an argument is a type of variable

Correct Answer: A parameter is a variable in a function definition; an argument is the value passed to it Rationale: A parameter is a variable listed in a function definition that receives a value. An argument is the actual value passed into the function when it is called. They are related but distinct concepts.

  1. What is the most likely outcome of using a loop without a proper termination condition? A) The loop will execute once and stop B) The loop may run indefinitely, causing an infinite loop C) The loop will automatically correct itself D) The loop will skip all iterations Correct Answer: The loop may run indefinitely, causing an infinite loop Rationale: A loop without a proper termination condition may run indefinitely, causing an infinite loop that never stops. This can freeze the program or consume excessive resources. It will not execute once and stop, self-correct, or skip iterations.
  2. Which of the following is an example of abstraction in programming? A) Using a library function without knowing its internal implementation B) Writing a loop to iterate through a list C) Declaring a variable with a specific data type D) Sorting an array in ascending order Correct Answer: Using a library function without knowing its internal implementation Rationale: Using a library function is procedural abstraction: the programmer knows what the function does but not how it works internally. Writing loops, declaring variables, and sorting are separate programming tasks.

Correct Answer: Last-In, First-Out (LIFO) Rationale: A stack follows the LIFO principle, meaning the most recently added element is the first one removed. Queues follow FIFO, arrays allow random access by index, and linked lists use pointers.

  1. Which data structure follows the First-In, First-Out (FIFO) principle? A) Stack B) Queue C) Array D) Graph Correct Answer: Queue Rationale: A queue follows FIFO, meaning the first element added is the first one removed. Stacks follow LIFO, arrays allow indexed access, and graphs model relationships between nodes.
  2. What is the most likely benefit of using a linked list over an array? A) Linked lists allow faster random access by index B) Linked lists are dynamic in size and easier to insert or delete elements C) Linked lists use less memory than arrays D) Linked lists store elements in contiguous memory Correct Answer: Linked lists are dynamic in size and easier to insert or delete elements Rationale: Linked lists are dynamic in size and make insertion and deletion operations easier than arrays because they use pointers to connect nodes. Arrays provide faster random access by index and use contiguous memory.
  1. According to the module, which term refers to a data structure where nodes are connected by edges to model relationships? A) Array B) Stack C) Graph D) Queue Correct Answer: Graph Rationale: A graph is a data structure consisting of nodes (vertices) connected by edges, used to model relationships and networks. Arrays, stacks, and queues are linear data structures with different organizational principles.
  2. What is the primary purpose of a tree data structure? A) To store elements in a linear sequence B) To represent hierarchical relationships between nodes C) To follow the LIFO principle D) To follow the FIFO principle Correct Answer: To represent hierarchical relationships between nodes Rationale: A tree is a hierarchical data structure consisting of nodes, with a root at the top and children branching below. It represents hierarchical relationships. Linear sequences, LIFO, and FIFO are characteristics of other data structures.
  3. In a tree data structure, what is the root? A) A node with no children B) The topmost node of the tree C) A node connected to exactly one other node D) The last node in the tree