Subroutines

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/27

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

28 Terms

1
New cards

Subroutine

A named set of instructions executed when called.

2
New cards

Procedure

A subroutine that performs a task without returning values.

3
New cards

Function

A subroutine that returns one or more values.

4
New cards

Built-in functions

Predefined functions in programming languages for common tasks.

5
New cards

Library subroutines

Predefined subroutines available through imported modules.

6
New cards

Parameters

Variables in subroutine definitions that accept input.

7
New cards

Arguments

Values passed to subroutines during calls.

8
New cards

Passing by value

Copies argument value to parameter, no changes affect original.

9
New cards

Passing by reference

Passes address of argument; changes affect original value.

10
New cards

Local variable

Defined within a subroutine, inaccessible outside it.

11
New cards

Global variable

Defined in the main program, accessible in any subroutine.

12
New cards

Scope of variable

The context in which a variable is accessible.

13
New cards

Modular programming

Breaking down tasks into smaller, manageable subtasks.

14
New cards

Advantages of local variables

Prevents accidental changes to main program variables.

15
New cards

Advantages of modular programming

Easier debugging, testing, and program management.

16
New cards

Return statement

Used in functions to send values back to caller.

17
New cards

Procedure call

Execution of a subroutine from the main program.

18
New cards

Function call

Execution of a function that returns a value.

19
New cards

Subroutine execution flow

Program jumps to subroutine, then returns to caller.

20
New cards

Parameter order

Sequence of parameters matters in subroutine calls.

21
New cards

Example of built-in function

sqrt(num) computes the square root of num.

22
New cards

Example of library subroutine

random.randint(1,6) generates a random integer.

23
New cards

Output of multiply(2,5)

Displays the product of 2 and 5.

24
New cards

Variable initialization

Assigning initial values to variables before use.

25
New cards

Function returning multiple values

A function can return several outputs using tuples.

26
New cards

Independent subroutines

Subroutines that can be reused across different programs.

27
New cards

Subroutine definition

Specifies parameters and instructions for a subroutine.

28
New cards

Error in variable scope

Accessing a local variable outside its defined scope.