Free Practice Quiz Question List

01 Programming Foundations and Problem Solving Online Quiz Questions

Use this free practice quiz with 20 questions to review 01 Programming Foundations and Problem Solving, test your knowledge, and prepare for your next test or exam.

20 questions
01
Choose one
1 point

Given the conditional if temperature > 30: message = "Hot" elif temperature > 20: message = "Mild" else: message = "Cool", what value is assigned to message when temperature is 25?

  1. A

    Hot

  2. B

    Mild

  3. C

    Cool

  4. D

    The program produces an error

02
True or false
1 point

True or false: A loop can become infinite if its condition never becomes false and its repeated work never makes progress toward termination.

  1. A

    True

  2. B

    False

03
Written response
1 point

Which computational-thinking practice means breaking a large problem into smaller tasks?

04
Fill in the blank
1 point

Complete the statement: An algorithm must be , meaning that it eventually terminates for valid input.

05
Choose one
1 point

Which statement correctly distinguishes parameters from arguments in a function?

  1. A

    Parameters are supplied values, while arguments are names in the definition.

  2. B

    Parameters and arguments are unrelated to function calls.

  3. C

    Parameters are names in the definition, while arguments are supplied values.

  4. D

    Parameters are return values, while arguments determine scope.

06
Choose all
1 point

Select all statements that are supported by the guidance on loops.

  1. A

    A for loop is useful when processing each item in a collection.

  2. B

    Every for loop must use a numeric index.

  3. C

    A loop should make progress toward a clear termination condition.

  4. D

    Every loop must contain a break statement.

07
True or false
1 point

True or false: A method is a function associated with an object or class and is often called through that object.

  1. A

    True

  2. B

    False

08
Written response
1 point

What object-oriented concept allows code to use a common interface while different object types provide different implementations?

09
Fill in the blank
1 point

Complete the statement: In the indexing convention described, the first element of an array is at index .

10
Choose one
1 point

A designer is modeling a Car that contains an Engine. Which relationship is generally the better choice, and why?

  1. A

    Inheritance, because a car is a type of engine

  2. B

    Composition, because a car has or uses an engine

  3. C

    Polymorphism, because an engine is always a subclass of car

  4. D

    Abstraction, because cars do not have behavior

11
Choose all
1 point

Select all actions that are recommended debugging strategies.

  1. A

    Read the complete error message and identify the relevant line.

  2. B

    Reproduce the problem with the smallest useful input.

  3. C

    Change many things at once so the fix is faster.

  4. D

    Inspect intermediate values and compare behavior with a hand-worked example.

12
Open ended
1 point

Design and explain an algorithm that counts how many values in a collection are greater than a specified threshold. Describe the key inputs and steps, explain how you would test it, and state how its running time grows as the collection size increases.

13
Choose one
1 point

Which statement best explains the distinction described between static and dynamic typing?

  1. A

    Static typing means all values are strings.

  2. B

    Static typing means errors can occur only at runtime.

  3. C

    Static typing generally checks a variable's type before execution.

  4. D

    Static typing prevents a program from using functions.

14
Choose one
1 point

Which statement best distinguishes a compiler from an interpreter?

  1. A

    An interpreter executes source code during program execution, while a compiler translates source code into lower-level code.

  2. B

    A compiler executes source code line by line, while an interpreter produces a standalone executable.

  3. C

    A compiler stores variables, while an interpreter defines functions.

  4. D

    An interpreter checks only syntax, while a compiler checks only runtime errors.

15
True or false
1 point

True or false: A for loop is generally the more appropriate choice when processing every item in a collection.

  1. A

    True

  2. B

    False

16
Written response
1 point

What programming term describes a loop that never makes progress toward its termination condition?

17
Choose one
1 point

A developer breaks a large application requirement into smaller, manageable tasks before designing the solution. Which computational-thinking practice is being applied?

  1. A

    Abstraction

  2. B

    Pattern recognition

  3. C

    Decomposition

  4. D

    Evaluation

18
Choose one
1 point

An algorithm counts how many values in a collection are greater than a threshold by examining each value exactly once. What is its running-time classification in terms of the number of values, nn?

  1. A

    O(1)O(1)

  2. B

    O(n)O(n)

  3. C

    O(n2)O(n^2)

  4. D

    O(log⁡n)O(\log n)

19
Choose one
1 point

A designer needs to model a Car that uses an Engine. Which design choice best follows the guidance in the material?

  1. A

    Use inheritance because every useful relationship should be an inheritance relationship.

  2. B

    Use inheritance because an engine is a specialized kind of car.

  3. C

    Use composition because a car contains or uses an engine.

  4. D

    Use neither because objects cannot collaborate across classes.

20
Written response
1 point

A function is required to count values greater than 10. It runs successfully, but its condition is written as value >= 10, so it incorrectly includes 10. What type of error is present?