Python Functions

Shared by a Flashcards.gg user · generated with AI · Report this set

Covers Python built-in functions, their definitions, and basic syntax for programmers.

20 cards English Level: Beginner Programming Published
Tap the card to flip it

Cards · 20

print()
Outputs specified values to the screen. Syntax: print(*objects, sep=' ', end='\n', file=None, flush=False).
len()
Returns the number of items in an object. Syntax: len(s), where s is a sequence (such as string, list, tuple) or collection.
type()
Returns the data type of an object. Syntax: type(object) or type(name, bases, dict) for dynamic class creation.
range()
Generates an immutable sequence of numbers. Syntax: range(stop) or range(start, stop[, step]).
int()
Converts a number or string into an integer. Syntax: int(x=0, base=10), where base specifies the numeral base of the string.
str()
Converts a given object into a string representation. Syntax: str(object='', encoding='utf-8', errors='strict').
float()
Returns a floating-point number constructed from a number or string. Syntax: float(x=0.0).
input()
Reads a line from standard input as a string. Syntax: input(prompt=''), where prompt is an optional string printed before reading.
sum()
Sums the items of an iterable from left to right. Syntax: sum(iterable, /, start=0), where start is added to the total.
max()
Returns the largest item in an iterable or the largest of two or more arguments. Syntax: max(iterable, *[, key, default]) or max(arg1, arg2, *args[, key]).
min()
Returns the smallest item in an iterable or the smallest of two or more arguments. Syntax: min(iterable, *[, key, default]) or min(arg1, arg2, *args[, key]).
sorted()
Returns a new sorted list from the items in an iterable. Syntax: sorted(iterable, /, *, key=None, reverse=False).
enumerate()
Returns an enumerate object yielding pairs of index and value. Syntax: enumerate(iterable, start=0).
zip()
Aggregates elements from each of the iterables in parallel. Syntax: zip(*iterables, strict=False).
abs()
Returns the absolute value of a given number. Syntax: abs(x), where x can be an integer, float, or complex number.
round()
Rounds a number to a given precision in decimal digits. Syntax: round(number, ndigits=None).
isinstance()
Checks if an object is an instance or subclass of a classinfo. Syntax: isinstance(object, classinfo), returning a boolean.
map()
Applies a specified function to all items in an input list or iterable. Syntax: map(function, iterable, *iterables).
filter()
Constructs an iterator from elements of iterable for which function returns true. Syntax: filter(function, iterable).
any()
Returns True if any element of the iterable is true; otherwise, returns False. Syntax: any(iterable).