Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SASS VUE GEN AI SCIPY CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING BASH RUST

Python Tutorial

Python HOME Python Intro Python Get Started Python Syntax Python Comments Python Variables Python Data Types Python Numbers Python Casting Python Strings Python Booleans Python Operators Python Lists Python Tuples Python Sets Python Dictionaries Python If...Else Python Match Python While Loops Python For Loops Python Functions Python Decorators Python Range Python Lambda Python Arrays Python OOP Python Classes/Objects Python Inheritance Python Iterators Python Polymorphism Python Scope Python Modules Python Dates Python Math Python JSON Python RegEx Python PIP Python Try...Except Python String Formatting Python None Python User Input Python VirtualEnv

File Handling

Python File Handling Python Read Files Python Write/Create Files Python Delete Files

Python Modules

NumPy Tutorial Pandas Tutorial SciPy Tutorial Django Tutorial

Python Matplotlib

Matplotlib Intro Matplotlib Get Started Matplotlib Pyplot Matplotlib Plotting Matplotlib Markers Matplotlib Line Matplotlib Labels Matplotlib Grid Matplotlib Subplot Matplotlib Scatter Matplotlib Bars Matplotlib Histograms Matplotlib Pie Charts

Machine Learning

Getting Started Mean Median Mode Standard Deviation Percentile Data Distribution Normal Data Distribution Scatter Plot Linear Regression Polynomial Regression Multiple Regression Scale Train/Test Decision Tree Confusion Matrix Hierarchical Clustering Logistic Regression Grid Search Categorical Data K-means Bootstrap Aggregation Cross Validation AUC - ROC Curve K-nearest neighbors

Python DSA

Python DSA Lists and Arrays Stacks Queues Linked Lists Hash Tables Trees Binary Trees Binary Search Trees AVL Trees Graphs Linear Search Binary Search Bubble Sort Selection Sort Insertion Sort Quick Sort Counting Sort Radix Sort Merge Sort

Python MySQL

MySQL Get Started MySQL Create Database MySQL Create Table MySQL Insert MySQL Select MySQL Where MySQL Order By MySQL Delete MySQL Drop Table MySQL Update MySQL Limit MySQL Join

Python MongoDB

MongoDB Get Started MongoDB Create DB MongoDB Collection MongoDB Insert MongoDB Find MongoDB Query MongoDB Sort MongoDB Delete MongoDB Drop Collection MongoDB Update MongoDB Limit

Python Reference

Python Overview Python Built-in Functions Python String Methods Python List Methods Python Dictionary Methods Python Tuple Methods Python Set Methods Python File Methods Python Keywords Python Exceptions Python Glossary

Module Reference

Built-in Modules Random Module Requests Module Statistics Module Math Module cMath Module

Python How To

Remove List Duplicates Reverse a String Add Two Numbers

Python Examples

Python Examples Python Compiler Python Exercises Python Quiz Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Certificate Python Training

Python builtins Module

❮ Standard Library Modules


Example

Use a few common built-in functions:

# Names: Emil, Tobias, Linus
print(len(["Emil", "Tobias"]))
print(sum([1, 2, 3]))
Try it Yourself »

Definition and Usage

The builtins module provides direct access to all built-in identifiers of Python.

Use it to reference built-in functions, exceptions, and constants explicitly, or to inspect/override built-ins.


Members

Member Description
abs()Return the absolute value of a number.
all()Return True if all elements of the iterable are true.
any()Return True if any element of the iterable is true.
ascii()Return a readable string of an object with non-ASCII characters escaped.
bin()Convert an integer to a binary string prefixed with 0b.
bool()Return a Boolean value.
bytearray()Create a mutable sequence of bytes.
bytes()Create an immutable sequence of bytes.
callable()Return True if the object appears callable.
chr()Return the string representing a character for the given Unicode code point.
classmethod()Return a method that receives the class as the first argument (cls); used as a decorator for defining class methods.
dict()Create a new dictionary.
dir()Return a list of names in the current scope or attributes of an object.
divmod()Return the pair (quotient, remainder) of dividing two numbers.
enumerate()Return an enumerate object.
eval()Evaluate a string as a Python expression and return the result.
exec()Execute Python code dynamically.
filter()Construct an iterator from elements of iterable for which function returns true.
float()Construct a floating point number.
format()Return a formatted string using the given format spec.
frozenset()Create an immutable set.
getattr()Return the value of the named attribute of an object; fallback if missing.
globals()Return a dict of the current global symbol table.
hasattr()Return True if an object has the named attribute.
hash()Return the hash value of the object (if it has one).
help()Invoke the built-in help system.
hex()Convert an integer to a hexadecimal string prefixed with 0x.
id()Return the identity (memory address) of an object.
input()Read a line from input, returning it as a string.
int()Construct an integer number.
isinstance()Return True if an object is an instance of a class or tuple of classes.
issubclass()Return True if a class is a subclass of another class or tuple of classes.
iter()Return an iterator from an object.
len()Return the number of items in a container.
list()Create a new list.
map()Return an iterator that applies function to every item of iterable.
max()Return the largest item in an iterable or the largest of two or more arguments.
memoryview()Create a memory view object of the given bytes-like object.
min()Return the smallest item in an iterable or the smallest of two or more arguments.
next()Retrieve the next item from an iterator; default if exhausted.
oct()Convert an integer to an octal string prefixed with 0o.
open()Open file and return a corresponding file object.
ord()Return the Unicode code point of a one-character string.
pow()Return base raised to power; with three args, compute modular exponentiation.
print()Print objects to text stream file.
property()Return a property attribute; used as a decorator to define managed attributes (with optional getter/setter/deleter).
range()Return an immutable sequence of numbers.
repr()Return a string with a printable representation of an object.
reversed()Return a reverse iterator over a sequence.
round()Round a number to a given precision in decimal digits.
set()Create a new set object.
slice()Create a slice object to specify how to slice a sequence.
sorted()Return a new sorted list from the items in iterable.
staticmethod()Return a static method; used as a decorator to define methods that do not receive an implicit first argument.
str()Return a string version of object.
sum()Sum items of an iterable.
super()Return a proxy object that delegates method calls to a parent or sibling class.
tuple()Create a new tuple.
type()Return the type of an object; can also create new types.
vars()Return the __dict__ attribute for a module, class, instance, or the current locals.
zip()Return an iterator of tuples, where the i-th tuple contains the i-th element from each of the argument iterables.

❮ Standard Library Modules

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2025 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.