Which statement correctly describes filtering in a data-processing program?
9 Fundamental Programming Techniques Online Quiz Questions
Use this free practice quiz with 20 questions to review 9 Fundamental Programming Techniques, test your knowledge, and prepare for your next test or exam.
A program must read exam scores, validate them, calculate an average, find the highest score, and display a report. Which design best applies decomposition?
- A
Putting all operations in one function to avoid function calls
- B
Repeating the same calculation in several places
- C
Dividing the problem into smaller tasks with clear purposes
- D
Replacing every loop with a list comprehension
True or false: When a loop accumulates a sum, the accumulator should normally be initialized to 0.
- A
True
- B
False
A function must return the first even number in a sequence. Which implementation strategy is most appropriate?
- A
Inspect every item and return the last matching item
- B
Return immediately when the first matching item is found
- C
Sort the sequence before checking for a match
- D
Return -1 whenever a matching item is found
What naming convention should normally be used for Python function and variable names, such as the name passing_scores?
Complete the statements about an index search: Use when both the position and value are needed; a conventional return value for an absent index is .
Select all the categories of test cases that a well-designed Python test suite should consider.
- A
Typical cases
- B
Boundary cases
- C
Invalid cases
- D
Special cases
- E
Only cases with positive integers
The function total_passing_scores processes the values ["72", "58", "invalid", 91, None] with minimum=60. What total does it return?
Complete this debugging plan: Use to inspect each position and value, then form one about the cause before changing the code.
Which design best makes a function for counting passing scores reusable and easy to test?
- A
A function accepts scores and returns the count, while separate code handles input and printing
- B
A function reads input, performs every operation, and prints the result internally
- C
A function prints intermediate values instead of returning a result
- D
A function stores all input and output in global variables
Select all the practices that improve the clarity and maintainability of Python code.
- A
Use descriptive names such as passing_scores
- B
Prefer early returns when they avoid deep nesting
- C
Use except Exception: pass to hide unexpected failures
- D
Write comments that explain intent or non-obvious decisions
True or false: Using except Exception: pass is generally a poor debugging practice because it can hide unexpected errors.
- A
True
- B
False
Explain how decomposition can improve a Python program that analyzes exam scores. Include at least three focused stages and explain two benefits of using separate functions or stages.
After reproducing a defect and reading its traceback, which next action best supports systematic debugging?
- A
Add more unrelated features until the failure disappears
- B
Change several parts of the program at once
- C
Reduce the problem to the smallest example that still fails
- D
Suppress the traceback and continue
True or false: Tests should be independent so that one test's result does not depend on the order in which unrelated tests run.
- A
True
- B
False
A program converts every name in ['ada', 'grace', 'margaret'] to title case and keeps the same number of items. Which programming technique is being applied?
- A
Filtering
- B
Transformation
- C
Reduction
- D
Decomposition
You are writing a loop to sum the values in a list. Which initial accumulator value is appropriate before the first iteration?
- A
-1
- B
1
- C
0
- D
The first value in the list
A function must return the first even number in a sequence and should avoid unnecessary work after finding it. Which implementation approach best matches this requirement?
- A
Sort the list before checking it
- B
Use a loop with an early
return - C
Use a list comprehension that checks every item
- D
Return the final item after the loop
What programming technique divides a large problem into smaller tasks, each with a clear purpose?
Which Python built-in should you use when searching through a sequence and needing both each item's position and its value?
Related study packs and tools
2 Digital Logic
A 14-question medium-difficulty quiz on Boolean algebra, logic gates, truth tables, and combinational circuits.
03 — Python Programming Fundamentals
A focused set of flashcards covering Python variables, data types, expressions, control flow, functions, input, output, and common programming practices.
04 Conditionals and Boolean Logic
Learn how Boolean expressions, logical operators, and conditional structures let programs make reliable decisions, including how to handle boundaries, branch order, and testing.
6 Computer Memory
Learn how computer memory stores and addresses information, how RAM and ROM differ, and how caches and the memory hierarchy balance speed, capacity, and cost.
07 Trees and Binary Search Trees
A progressive guide to tree structure, binary-tree traversals, binary search tree operations, deletion, balancing, and the way tree height determines time and space costs.
12 — Foundations Capstone: Integrating Computer Science
A practical guide to integrating problem definition, data representation, modular programming, algorithms, complexity analysis, testing, correctness, and ethical evaluation into a responsible computer science capstone.
Interrupts
Reviews how interrupts support event handling and multitasking, and how Linux system calls use the RISC-V `ecall` instruction and register conventions.
OS Processes
This quiz covers process management, context switching and scheduling, multitasking, traps and interrupts, and RISC-V privilege transitions.
Systemcalls
A quiz on operating-system system calls, including privileged-operation requests, process creation and execution with fork, exec, and waitpid, and signal handling.