|
print()
|
print(*objects, sep=" ", end="\n", file=sys.stdout...
|
Prints objects to the text stream, separated by sep and followed by end.
|
Details →
|
|
len()
|
len(s)
|
Returns the number of items in a container (string, list, tuple, dict, set, etc.).
|
Details →
|
|
range()
|
range(stop) range(start, stop, step)
|
Returns an immutable sequence of numbers. Commonly used in for loops.
|
Details →
|
|
type() / isinstance()
|
type(object) isinstance(object, classinfo)
|
type() returns the type of an object; isinstance() checks if an object is an instance of a class.
|
Details →
|
|
enumerate()
|
enumerate(iterable, start=0)
|
Adds a counter to an iterable, returning (index, value) pairs. Avoids manual counter variables.
|
Details →
|
|
zip()
|
zip(*iterables)
|
Aggregates elements from multiple iterables into tuples. Stops at the shortest iterable.
|
Details →
|
|
map() / filter()
|
map(function, iterable) filter(function, iterable...
|
map() applies a function to each item; filter() keeps items where the function returns True.
|
Details →
|
|
sorted() / reversed()
|
sorted(iterable, key=None, reverse=False)
|
sorted() returns a new sorted list; reversed() returns a reverse iterator. Neither modifies the original.
|
Details →
|
|
open() / with statement
|
open(file, mode='r', encoding=None)
|
Opens a file and returns a file object. Always use with statement to ensure the file is properly closed.
|
Details →
|
|
int() / float() / str()
|
int(x) float(x) str(x)
|
Convert values between types. Raises ValueError if conversion is not possible.
|
Details →
|