CSC 1301 - Chapter 7: Advanced Functions and Strings

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

1/27

flashcard set

Earn XP

Description and Tags

Vocabulary practice flashcards covering function arguments, keyword arguments, default parameters, arbitrary argument lists (*args, **kwargs), multiple returns, string slicing, advanced string formatting, string methods, and splitting/joining strings.

28 Terms

1
New cards

Pass-by-assignment

Python's argument-passing mechanism where arguments are passed by object reference, binding parameter names in the function's local namespace to the passed argument objects.

2
New cards

Immutable argument modification

A behavior where any modification to an immutable parameter (such as an integer or string) inside a function creates a new local object, leaving the original argument object unchanged outside the function.

3
New cards

Mutable argument modification

In-place modifications to mutable parameters (such as lists or dictionaries) within a function that persist outside the function's scope and affect other variables referencing that same object.

4
New cards

Keyword argument

An argument syntax that maps arguments to parameters explicitly by name rather than implicitly by position in the argument list.

5
New cards

Default parameter value

A predefined value assigned to a parameter in a function definition that is used if the corresponding argument is omitted from the function call.

6
New cards

Mutable default object problem

An issue where a mutable default parameter (such as an empty list) is created only once when the function is defined, causing modifications to persist across multiple function calls.

7
New cards

*args

A function definition parameter that collects optional positional arguments into an arbitrary argument list tuple.

8
New cards

**kwargs

A function definition parameter that collects extra keyword arguments into a dictionary whose keys match the argument names passed in the function call.

9
New cards

Multiple function outputs

The technique of packaging several values into a single container object, typically a tuple, to allow a function's single return statement to yield multiple values.

10
New cards

Unpacking

An operation that performs multiple assignments simultaneously to assign individual elements of a returned tuple or list to separate variables.

11
New cards

Index (string)

An integer matching a specific position in a sequence of characters, starting at 00 for the first character.

12
New cards

Slice notation

Syntax of the form my_str[start:end] that creates a new string containing characters from index start up to end - 1.

13
New cards

Stride

The optional third integer in slice notation (my_str[start:end:stride]) that determines how much to increment the index after reading each element, defaulting to 11.

14
New cards

Field width

A format specification component defined by an integer after a colon (such as {name:16}) that defines the minimum number of character spaces to output, padding with spaces by default.

15
New cards

Alignment character

A format specification character placed before the field width that determines whether a value is left-aligned (

16
New cards

Fill character

A character placed before the alignment symbol in a format specification (defaulting to an empty space) used to pad a replacement field when the inserted value is shorter than the field width.

17
New cards

Precision component

An optional format specification element starting with a period (such as :.2f) that indicates how many digits to display to the right of the decimal point for floating-point numbers.

18
New cards

replace()

A string method that returns a copy of the string with occurrences of an old substring replaced by a new substring, optionally limited to a specified count.

19
New cards

find()

A string method that searches for an item and returns the index of its first occurrence, or −1-1 if the item is not found.

20
New cards

rfind()

A string method that searches a string in reverse and returns the index of the last occurrence of the specified item.

21
New cards

count() (string method)

A string method that returns the number of times a specified substring occurs within the string.

22
New cards

in (string membership operator)

An operator that examines whether a character or substring exists anywhere within another string, evaluating to True or False.

23
New cards

Boolean string methods

A category of methods (including isalnum(), isdigit(), islower(), isupper(), and isspace()) that test string character content and return True or False.

24
New cards

strip()

A string method that returns a copy of a string with all leading and trailing whitespace removed.

25
New cards

Token

A substring that forms a constituent part of a larger string after being partitioned by a separator.

26
New cards

Separator

A character or sequence of characters that indicates the boundaries where a string is divided into tokens, or the character inserted between elements when joining.

27
New cards

split()

A string method that separates a string into a list of tokens based on a specified separator string, defaulting to any whitespace character.

28
New cards

join()

A string method that concatenates a list of strings into a single string, inserting the calling separator string between each list element.