Skip to content
UPEEC

Output, Input and Inspection

print, input, len, type, help, repr, id, hash, dir and friends.

Beginner
Comments 0

This is an overview — pick a sub-topic below.

Sub-topics (11)

print()

Writes values to the screen (or a file), separated by sep and ended by end.

Beginner♥ 0🔖 0💬 0

input()

Reads one line from the keyboard as a string (without the newline).

Beginner♥ 0🔖 0💬 0

len()

Returns the number of items in a string, list, tuple, dict, set or any object with __len__.

Beginner♥ 0🔖 0💬 0

type()

Returns an object's type; with three arguments it creates a new class dynamically.

Beginner♥ 0🔖 0💬 0

help()

Shows the documentation of a module, function or class in the interactive shell.

Beginner♥ 0🔖 0💬 0

repr()

Returns an unambiguous, developer-friendly string — what the REPL shows.

Beginner♥ 0🔖 0💬 0

format()

Formats a single value using the same mini-language as f-strings.

Easy♥ 0🔖 0💬 0

hash()

Returns the integer hash used by dicts and sets; only immutable (hashable) objects have one.

Easy♥ 0🔖 0💬 0

id()

Returns a unique integer identity for an object during its lifetime (its memory address in CPython).

Easy♥ 0🔖 0💬 0

dir()

Lists the attributes and methods of an object (or the names in the current scope).

Beginner♥ 0🔖 0💬 0

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.