What is a loop?
A loop repeats a block of instructions. It is useful for processing many values, repeating actions, or examining combinations of data.
Study 05 Loops and Repetition with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.
What is a loop?
A loop repeats a block of instructions. It is useful for processing many values, repeating actions, or examining combinations of data.
What four parts does a loop normally have?
Initialization establishes the starting state, the condition determines whether to continue, the body performs repeated work, and progress updates the state toward stopping.
When is a while loop appropriate?
A while loop repeats as long as its condition is true. It is appropriate when the number of repetitions depends on input or changing state.
When is a for loop usually the clearest choice?
A for loop processes each item in a sequence or iterable. It is usually clearest for handling every item in a collection.
What values does range(5) produce?
range(5) produces 0, 1, 2, 3, 4. The ending value is excluded.
Why use enumerate() in a for loop?
enumerate() supplies both an item’s position and its value, avoiding the need to maintain an index manually.
What is a counter?
A counter records how many times an event occurs. It is commonly initialized to zero and increased only when the event’s condition is satisfied.
What is an accumulator?
An accumulator combines many values into one result. Initialize it with the identity value: 0 for addition or 1 for multiplication.
What does break do?
break immediately terminates the innermost for or while loop. It is useful when the desired result has been found or further work is unnecessary.
What does continue do?
continue skips the rest of the current iteration and begins the next one. In a while loop, skipping an essential update can cause nontermination.
When does Python’s loop else clause run?
A loop else clause runs when the loop finishes normally, but not when break ends it. This supports searches where else reports that no match was found.
What is a nested loop?
A nested loop is a loop inside another loop. The inner loop completes all its iterations for each iteration of the outer loop.
A 14-question medium-difficulty quiz on Boolean algebra, logic gates, truth tables, and combinational circuits.
A focused set of flashcards covering Python variables, data types, expressions, control flow, functions, input, output, and common programming practices.
A structured guide to the main data structures, their operations, efficiency trade-offs, representations, and practical selection criteria.
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.
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.
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.
Reviews how interrupts support event handling and multitasking, and how Linux system calls use the RISC-V `ecall` instruction and register conventions.
This quiz covers process management, context switching and scheduling, multitasking, traps and interrupts, and RISC-V privilege transitions.
A quiz on operating-system system calls, including privileged-operation requests, process creation and execution with fork, exec, and waitpid, and signal handling.