How does Python identify code blocks?
Python uses indentation to identify which statements belong to an `if`, `while`, or `for` block. Statements in the same block must be indented consistently.
Study 3 Control Flow with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.
How does Python identify code blocks?
Python uses indentation to identify which statements belong to an `if`, `while`, or `for` block. Statements in the same block must be indented consistently.
What do Python's `and`, `or`, and `not` operators do?
`and` is true when both operands are true; `or` is true when at least one operand is true; `not` reverses a truth value.
What is short-circuit evaluation?
Short-circuit evaluation stops `and` when its left operand is false and stops `or` when its left operand is true, so unnecessary or unsafe expressions may not run.
Which common Python values are falsy?
Falsy values include `False`, `None`, numeric zero, and empty strings or collections. Most other objects are truthy.
When should Python use `==` rather than `is`?
Use `==` to compare values. Use `is` mainly for object identity checks involving singletons such as `None`.
What does `0 <= score <= 100` mean?
A chained comparison such as `0 <= score <= 100` expresses both comparisons and evaluates the middle expression only once.
How does Python choose among `if` and `elif` branches?
Python tests `if` and `elif` conditions from top to bottom and executes only the first matching branch. Remaining branches are skipped.
When does a `while` loop execute its body?
A `while` loop checks its condition before every iteration. If the condition is initially false, its body runs zero times.
When is a `while` loop appropriate?
Use a `while` loop when repetition depends on a condition that changes during execution or when the number of repetitions is not known in advance.
How does a Python `for` loop traverse data?
A `for` loop assigns each item from an iterable to a loop variable and runs its body. It ends when the iterable is exhausted.
How can a `for` loop obtain both index and item?
`enumerate()` supplies both an index and an item, as in `for index, name in enumerate(names):`.
Is the stop value included in `range()`?
The `stop` value in `range()` is exclusive. For example, `range(5)` produces the integers 0 through 4.
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.
Learn how Boolean expressions, logical operators, and conditional structures let programs make reliable decisions, including how to handle boundaries, branch order, and testing.
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.