What is a function?
Functions are named, reusable sections of a program that perform a focused task. They reduce repetition and make code easier to understand, test, and maintain.
Study 5 Functions and Program Structure with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.
What is a function?
Functions are named, reusable sections of a program that perform a focused task. They reduce repetition and make code easier to understand, test, and maintain.
What are the main parts of a function?
A function usually has a name, parameters, a body containing instructions, and a return value when it produces a result.
How does a definition differ from a call?
A function definition creates the function; a function call runs it. In Python, the `def` statement introduces a function definition.
What is the difference between a parameter and an argument?
A parameter is a variable listed in a function definition. An argument is the actual value supplied when the function is called.
How does returning differ from printing?
`return` sends a value back to the caller, where it can be stored, displayed, compared, or passed to another function. `print` only displays a value.
What does Python return without an explicit `return`?
In Python, reaching the end of a function without an explicit `return` produces `None`. A function with no useful result therefore still technically returns a value.
What does scope determine?
Scope is the region where a name can be accessed. A local variable normally exists only inside its function, while a global variable is defined at program or module level.
How do local variables support encapsulation?
Encapsulation keeps a function's internal state isolated through local variables. This helps prevent unrelated parts of a program from changing that state accidentally.
What does a function interface specify?
A function's interface includes its name, accepted parameters, possible values or errors, and important side effects such as writing a file or changing a database.
What do cohesion and coupling mean?
High cohesion means a module contains closely related responsibilities. Low coupling means modules depend on one another as little as practical.
What is function decomposition?
Function decomposition breaks a larger problem into focused tasks, gives each task a function, defines its data flow, connects the functions, and tests them independently before testing the whole program.
Why is code reuse valuable?
Code reuse means calling an existing function or module instead of rewriting the same algorithm. It reduces duplication and helps corrections apply consistently.
A progressive guide to how computers encode numbers, text, images, and sound as binary data, including the trade-offs and limits of digital representation.
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 focused review of propositional logic, quantifiers, sets, relations, functions, and foundational proof methods in discrete mathematics for computer science.
A progression through how data is organized, searched, exposed through software interfaces, and managed through abstraction layers in modern computer systems.
A medium-difficulty quiz on integrating problem definition, representation, algorithms, complexity analysis, testing, correctness, ethical evaluation, and documentation in a computer science capstone.
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.
This quiz covers process management, context switching and scheduling, multitasking, traps and interrupts, and RISC-V privilege transitions.