Free Practice Quiz Question List

8 Fundamental Programming Techniques Online Quiz Questions

Use this free practice quiz with 20 questions to review 8 Fundamental Programming Techniques, test your knowledge, and prepare for your next test or exam.

20 questions
01
Choose one
1 point

Which Python collection is most appropriate when a program needs to test membership frequently and remove duplicate values?

  1. A

    list

  2. B

    tuple

  3. C

    set

  4. D

    dict

02
True or false
1 point

True or false: A binary search can reliably find a target in an unsorted collection because it compares the target with the middle item at each step.

  1. A

    True

  2. B

    False

03
Written response
1 point

What programming term means a finite, precise procedure for solving a problem?

04
Fill in the blank
1 point

Complete the statement: In loop reasoning, a condition that remains true at a particular point in every iteration is called an .

05
Choose one
1 point

Which statement correctly compares Python's sorted() function with the list.sort() method?

  1. A

    sorted() returns a new list, while list.sort() changes the list in place.

  2. B

    sorted() changes a list in place, while list.sort() returns a new list.

  3. C

    Both sorted() and list.sort() always leave the original list unchanged.

  4. D

    Both sorted() and list.sort() require the list to contain only numbers.

06
Choose all
1 point

Which testing approaches should a systematic test plan include? Select all correct choices.

  1. A

    Typical cases with ordinary valid data

  2. B

    Boundary cases such as an empty collection or a minimum value

  3. C

    Invalid cases such as malformed text or an impossible value

  4. D

    Regression cases that previously exposed a defect

  5. E

    Only typical cases, because unusual inputs are outside the program's purpose

07
True or false
1 point

True or false: A function that calculates a result should generally return that result rather than print it directly.

  1. A

    True

  2. B

    False

08
Written response
1 point

What search method repeatedly halves a sorted search range and has worst-case growth of O(log⁡n)O(\log n) search steps?

09
Fill in the blank
1 point

Complete the comparison: Python's returns a new sorted list, whereas changes an existing list in place.

10
Choose all
1 point

Which elements belong in a useful function contract? Select all correct choices.

  1. A

    Inputs and accepted forms

  2. B

    The returned output

  3. C

    Side effects on files, displays, or other external state

  4. D

    Errors or failure behavior

11
Choose one
1 point

Which approach best follows the material's guidance for handling exceptions in a program that expects invalid user input?

  1. A

    Catch every possible exception at the top level and continue silently.

  2. B

    Catch a specific expected exception at the level where the program can respond meaningfully.

  3. C

    Avoid handling exceptions because they always indicate bugs in the program.

  4. D

    Use a broad except clause around the entire application to simplify debugging.

12
Open ended
1 point

The integrated word-frequency report is divided into several functions. Explain how this decomposition improves testability and clarity, identify the principal responsibility of each function, and state how the program makes ordering deterministic when words have equal frequencies.

13
Choose one
1 point

What is the time complexity of the selection_sort implementation described in the material?

  1. A

    O(n)O(n)

  2. B

    O(n2)O(n^2)

  3. C

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

  4. D

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

14
True or false
1 point

True or false: The line shown in a traceback is necessarily the location where the original incorrect value was created.

  1. A

    True

  2. B

    False

15
Choose one
1 point

A programmer wants to test a function that processes a collection. Which testing choice best follows the systematic testing guidance?

  1. A

    Use only ordinary valid inputs because they represent normal use.

  2. B

    Include boundary cases such as an empty collection, zero, or one item.

  3. C

    Replace the algorithm with a larger program before testing it.

  4. D

    Test only inputs that are expected to produce a successful result.

16
Choose one
1 point

A program receives a group of tags and must remove repeated tags while frequently checking whether a tag is present. Which Python collection is the most suitable choice?

  1. A

    A tuple, because it is ordered and immutable.

  2. B

    A list, because it is mutable and preserves order.

  3. C

    A set, because it supports membership tests and removes duplicates.

  4. D

    A dictionary, because every collection should use key–value pairs.

17
Choose one
1 point

A function calculates the total of a list of prices, and the result may later be used by both a report and an automated test. Which design is most appropriate?

  1. A

    Return the result from the calculation function and let another part handle display.

  2. B

    Print the result inside the calculation function so every caller sees it.

  3. C

    Store the result in global state instead of returning it.

  4. D

    Raise an exception whenever the result needs to be displayed.

18
Choose one
1 point

Before applying binary search to a collection, which condition must hold for the algorithm's discard-half reasoning to be valid?

  1. A

    The collection must contain only strings.

  2. B

    The target must be the first item in the collection.

  3. C

    The collection must be mutable.

  4. D

    The data must be sorted.

19
Written response
1 point

What programming term names a condition that remains true at a particular point in every iteration of an algorithm?

20
Written response
1 point

Using the find_index function described in the material, what value is returned by find_index([4, 8, 15], 8)?