What is a Python function?
A function is a named, reusable block of code that performs a specific task. It helps divide large problems, reduce repetition, and improve readability, testing, and maintenance.
Study 5 Functions and Modular Programming with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.
What is a Python function?
A function is a named, reusable block of code that performs a specific task. It helps divide large problems, reduce repetition, and improve readability, testing, and maintenance.
What is the difference between defining and calling a function?
The `def` statement defines a function and creates its function object; the function call, such as `greet()`, executes its indented body.
How does a parameter differ from an argument?
A parameter is the name listed in a function definition; an argument is the value supplied to that parameter in a function call.
How do positional and keyword arguments differ?
Positional arguments are matched by order, while keyword arguments are matched by parameter name. Positional arguments must come before keyword arguments.
When does Python use a default parameter value?
A default parameter value is used when the caller omits that argument. The default is evaluated when the function is defined, not on each call.
What do `*args` and `**kwargs` collect?
`*args` collects extra positional arguments into a tuple, while `**kwargs` collects extra keyword arguments into a dictionary.
What does `return` do?
`return` sends a value to the caller and immediately ends that function call. Unlike `print()`, it makes the result available for further computation.
What does a function return without `return`?
If execution reaches the end without a `return` statement, Python returns `None`. Printing a value does not automatically return it.
What does the LEGB rule describe?
LEGB is Python’s name-resolution order: Local, Enclosing, Global, then Built-in scope.
What does assignment inside a function usually create?
An assignment inside a function normally creates or updates a local variable, even when a module-level variable has the same name.
What is a function docstring?
A docstring is a string literal placed first in a function body. Python stores it in the function’s `__doc__` attribute for documentation tools and users.
What is modular problem-solving?
Modular problem-solving divides a program into focused components, designs their interfaces, tests them independently, composes them, and then refactors the result.
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.