Chapter 6:Python Functions, Scope, and Namespaces

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/29

flashcard set

Earn XP

Description and Tags

Comprehensive vocabulary flashcards covering Python functions, function stubs, parameters, typing systems, scopes, and namespaces from Chapter 6.

30 Terms

1
New cards

Function

A named series of predefined statements grouped together to perform repeated operations, reducing program redundancy and keeping the main program simple.

2
New cards

Function Definition

A statement block beginning with the def keyword and the function's name, followed by an indented body of statements that define the function's behavior.

3
New cards

Function Call

An invocation of a function's name that causes the program execution to jump to the function's statements and return after executing the last statement.

4
New cards

Parameter

A function input specified within the parentheses of a function definition, which is bound to an argument value when the function is called.

5
New cards

Argument

A specific value or expression passed to a function's parameter during a function call.

6
New cards

None

A special Python keyword that indicates no value, which is returned by default when a function contains no return statement or an empty return statement.

7
New cards

Hierarchical Function Call

A nested call where a function's statements include calls to other functions, or where a function call serves as an argument to another function (such as in int(input())).

8
New cards

Void Function

A function that performs an action (such as printing output) without returning a value, implicitly returning None.

9
New cards

Polymorphism

The behavior in which an operation or function depends on the involved object types, such as the + operator performing addition for numbers and concatenation for strings.

10
New cards

Dynamic Typing

A programming language feature where the interpreter determines object types during program execution and checks operation validity at runtime.

11
New cards

Static Typing

A programming language requirement (found in languages like C, C++, and Java) where the programmer must explicitly declare the type of every variable and parameter in the source code prior to compilation.

12
New cards

Duck Typing

A form of dynamic typing based on the maxim 'If a bird walks, swims, and quacks like a duck, then call it a duck,' treating an object based on the operations it supports rather than its declared class.

13
New cards

Modular Development

The process of dividing a program into separate modules or functions that can be written, tested individually, and integrated into a single system.

14
New cards

Mathematical Function

A function that executes a mathematical calculation involving one or more numerical parameters and returns a numerical result.

15
New cards

Incremental Development

A programming practice where a small amount of code is written and tested, followed by writing and testing additional small increments until completion.

16
New cards

Function Stub

A placeholder function definition whose statements have not yet been written, used to capture high-level program behavior during early development.

17
New cards

pass Statement

A Python keyword that performs no operation, serving as a syntactic placeholder where a code statement is required.

18
New cards

NotImplementedError

An exception raised in an unfinished function stub to immediately stop program execution when that stub is invoked.

19
New cards

Function Object

An entity created when a def statement is evaluated, possessing a type, identity, value, and compiled bytecode that supports the call operation.

20
New cards

Bytecode

Low-level operations generated by the Python interpreter when evaluating code, representing instructions like loading, adding, or storing values in memory.

21
New cards

Copy-Paste Error

A common mistake occurring when existing code is copied into a new function but the programmer fails to adjust all variable names, formulas, or return statements.

22
New cards

Scope

The specific area or portion of program code where a variable or function name is visible and accessible.

23
New cards

Local Variable

A variable defined inside a function whose visibility extends only from its first assignment to the end of that function.

24
New cards

Global Variable

A variable defined outside of any function whose visibility extends from its assignment to the end of the file.

25
New cards

global Statement

A Python statement required inside a function to permit assigning or re-binding a global variable rather than creating a local variable.

26
New cards

Namespace

An internal mapping structure (implemented as a Python dictionary) that tracks program objects by linking names to their corresponding values.

27
New cards

locals()

A built-in Python function that returns a dictionary containing all the names and objects located in the current local namespace.

28
New cards

globals()

A built-in Python function that returns a dictionary containing all the names and objects located in the global namespace.

29
New cards

Scope Resolution

The sequential process by which the Python interpreter searches through active namespaces (local, enclosing, global, and built-in) to find a referenced name.

30
New cards

Built-in Scope

The outermost scope that contains all pre-defined Python functions and constants, such as int(), input(), and str().