1/27
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Subroutine
A named set of instructions executed when called.
Procedure
A subroutine that performs a task without returning values.
Function
A subroutine that returns one or more values.
Built-in functions
Predefined functions in programming languages for common tasks.
Library subroutines
Predefined subroutines available through imported modules.
Parameters
Variables in subroutine definitions that accept input.
Arguments
Values passed to subroutines during calls.
Passing by value
Copies argument value to parameter, no changes affect original.
Passing by reference
Passes address of argument; changes affect original value.
Local variable
Defined within a subroutine, inaccessible outside it.
Global variable
Defined in the main program, accessible in any subroutine.
Scope of variable
The context in which a variable is accessible.
Modular programming
Breaking down tasks into smaller, manageable subtasks.
Advantages of local variables
Prevents accidental changes to main program variables.
Advantages of modular programming
Easier debugging, testing, and program management.
Return statement
Used in functions to send values back to caller.
Procedure call
Execution of a subroutine from the main program.
Function call
Execution of a function that returns a value.
Subroutine execution flow
Program jumps to subroutine, then returns to caller.
Parameter order
Sequence of parameters matters in subroutine calls.
Example of built-in function
sqrt(num) computes the square root of num.
Example of library subroutine
random.randint(1,6) generates a random integer.
Output of multiply(2,5)
Displays the product of 2 and 5.
Variable initialization
Assigning initial values to variables before use.
Function returning multiple values
A function can return several outputs using tuples.
Independent subroutines
Subroutines that can be reused across different programs.
Subroutine definition
Specifies parameters and instructions for a subroutine.
Error in variable scope
Accessing a local variable outside its defined scope.