{"id":1055,"date":"2020-11-12T01:20:58","date_gmt":"2020-11-12T01:20:58","guid":{"rendered":"https:\/\/www.pythontutorial.net\/?page_id=1055"},"modified":"2022-09-15T03:12:26","modified_gmt":"2022-09-15T03:12:26","slug":"python-built-in-functions","status":"publish","type":"page","link":"https:\/\/www.pythontutorial.net\/python-built-in-functions\/","title":{"rendered":"Python Built-in Functions"},"content":{"rendered":"\n<p>This page provides you with Python built-in functions and types for references.<\/p>\n\n\n\n<p><input id=\"search\" class=\"light-table-filter\" type=\"text\" placeholder=\"Type a function name to search...\" data-table=\"functions\" style=\"width:95%\"><\/p>\n\n\n\n<figure class=\"wp-block-table responsive functions\"><table><thead><tr><th>Name<\/th><th>Meaning<\/th><\/tr><\/thead><tbody><tr><td><a href=\"https:\/\/www.pythontutorial.net\/python-built-in-functions\/python-abs\/\">abs(x)<\/a><\/td><td>Return an absolute value of a number<\/td><\/tr><tr><td><a href=\"https:\/\/www.pythontutorial.net\/python-built-in-functions\/python-all\/\">all(iterable)<\/a><\/td><td>Return <code>True<\/code> if all elements of the <code>iterable<\/code> are true<\/td><\/tr><tr><td><a href=\"https:\/\/www.pythontutorial.net\/python-built-in-functions\/python-any\/\">any(iterable)<\/a><\/td><td>Return&nbsp;<code>True<\/code>&nbsp;if any element of the&nbsp;<code>iterable<\/code>&nbsp;is true<\/td><\/tr><tr><td>ascii()<\/td><td>Return a string that contains a printable representation of an object<\/td><\/tr><tr><td>bin()<\/td><td>Convert an integer to a binary string prefixed with <code>0b<\/code><\/td><\/tr><tr><td><a href=\"https:\/\/www.pythontutorial.net\/advanced-python\/python-bool\/\">bool(x)<\/a><\/td><td>Return a Boolean value, either <code>True<\/code> or <code>False<\/code> of <code>x<\/code><\/td><\/tr><tr><td>bytearray()<\/td><td>Return a new array of bytes<\/td><\/tr><tr><td>bytes([source[,&nbsp;encoding[,&nbsp;errors]]])<\/td><td>Return a new <code>bytes<\/code> object that is an immutable sequence of integers in the range <code>[0,256]<\/code><\/td><\/tr><tr><td><a href=\"https:\/\/www.pythontutorial.net\/python-built-in-functions\/python-callable\/\">callable(object)<\/a><\/td><td>Return <code>True<\/code> if the object is callable, <code>False<\/code> otherwise<\/td><\/tr><tr><td>chr(i)<\/td><td>Return the string representing a character whose Unicode code point is the integer&nbsp;<code>i<\/code><\/td><\/tr><tr><td>@classmethod<\/td><td>Transform a <a href=\"https:\/\/www.pythontutorial.net\/python-oop\/python-methods\/\">method<\/a> into a <a href=\"https:\/\/www.pythontutorial.net\/python-oop\/python-class-methods\/\">class method<\/a>.<\/td><\/tr><tr><td>delattr(object, name)<\/td><td>Delete the attribute specified by <code>name<\/code> from the <code>object<\/code> if the object allows it.<\/td><\/tr><tr><td>dict()<\/td><td>Create a new dictionary<\/td><\/tr><tr><td>dir([object])<\/td><td>Return a list of names in the current local scope or return a list of valid attributes of the object if the <code>object<\/code> is specified.<\/td><\/tr><tr><td>divmod(a,b)<\/td><td>Accept two numbers and return a tuple of two numbers that consists of their quotient and remainder when using integer division. <br>For integers, the result is the same as <code>(a&nbsp;\/\/&nbsp;b,&nbsp;a&nbsp;%&nbsp;b)<\/code><\/td><\/tr><tr><td><a href=\"https:\/\/www.pythontutorial.net\/python-built-in-functions\/python-enumerate\/\">enumerate()<\/a><\/td><td>Iterate over an iterable with a counter<\/td><\/tr><tr><td>eval(expression[,&nbsp;globals[,&nbsp;locals]])<\/td><td>Run the Python <code>expression<\/code> with the optional <code>globals<\/code> and <code>locals<\/code><\/td><\/tr><tr><td>exec(object[,&nbsp;globals[,&nbsp;locals]])<\/td><td>Dynamically execute Python code with the optional <code>globals<\/code> and <code>locals<\/code><\/td><\/tr><tr><td><a href=\"https:\/\/www.pythontutorial.net\/python-basics\/python-filter-list\/\">filter()<\/a><\/td><td>Filter elements of a list<\/td><\/tr><tr><td><a href=\"https:\/\/www.pythontutorial.net\/python-built-in-functions\/python-float\/\">float(x)<\/a><\/td><td>Convert a string or a number (<code>x<\/code>) into a floating point number<\/td><\/tr><tr><td>format(value[, format_spec])<\/td><td>Convert the&nbsp;<code>value<\/code>&nbsp;to a formatted representation, as controlled by&nbsp;<code>format_spec<\/code>.<\/td><\/tr><tr><td>frozenset([iterable])<\/td><td>Return a new frozenset object with elements from the iterable<\/td><\/tr><tr><td><a href=\"https:\/\/www.pythontutorial.net\/python-built-in-functions\/python-getattr\/\">getattr(object,&nbsp;name[,&nbsp;default])<\/a><\/td><td>Return the value of the <code>name<\/code> attribute of the <code>object<\/code> or <code>default<\/code> if the <code>name<\/code> attribute doesn&#8217;t exist.<\/td><\/tr><tr><td>globals()<\/td><td>Return a dictionary that contains all global variables in the current module<\/td><\/tr><tr><td><a href=\"https:\/\/www.pythontutorial.net\/python-built-in-functions\/python-hasattr\/\">hasattr(object, name)<\/a><\/td><td>Return <code>True<\/code> if the object has an attribute specified by <code>name<\/code> or <code>False<\/code> otherwise.<\/td><\/tr><tr><td><a href=\"https:\/\/www.pythontutorial.net\/python-oop\/python-__hash__\/\">hash()<\/a><\/td><td>Return the value as an integer of an object. Python uses the hash values to quickly compare dictionary keys for faster lookup.<\/td><\/tr><tr><td>help([object])<\/td><td>Call the built-in help system<\/td><\/tr><tr><td>hex(x)<\/td><td>Convert an integer (<code>x<\/code>) to a lowercase hexadecimal string prefixed with <code>0x<\/code>.<\/td><\/tr><tr><td><a href=\"https:\/\/www.pythontutorial.net\/python-built-in-functions\/python-id\/\">id(object)<\/a><\/td><td>Return an integer which is an identity of an object<\/td><\/tr><tr><td>input([prompt])<\/td><td>Read a line from the input, convert it to a string (removing a trailing newline), and return that string.<\/td><\/tr><tr><td><a href=\"https:\/\/www.pythontutorial.net\/python-built-in-functions\/python-int\/\">int()<\/a><\/td><td>Convert a string or a number to an integer<\/td><\/tr><tr><td>isinstance(object,classinfo)<\/td><td>Return true of the <code>object<\/code> is an instance of the <code>classinfo<\/code> or an instance of a subclass of the <code>classinfo<\/code>.<\/td><\/tr><tr><td>issubclass(class,classinfo)<\/td><td>Return True if the <code>class<\/code> is a subclass of <code>classinfo<\/code>.<\/td><\/tr><tr><td><a href=\"https:\/\/www.pythontutorial.net\/advanced-python\/python-iter\/\">iter()<\/a><\/td><td>Return an iterator of a given object<\/td><\/tr><tr><td><a href=\"https:\/\/www.pythontutorial.net\/python-built-in-functions\/python-len\/\">len(s)<\/a><\/td><td>Return the length (or the number of items) of an object.<\/td><\/tr><tr><td>list([iterable])<\/td><td>Return a List object from the iterable<\/td><\/tr><tr><td>locals()<\/td><td>Update and return a dictionary that stores the current local symbol table.<\/td><\/tr><tr><td><a href=\"https:\/\/www.pythontutorial.net\/python-basics\/python-map-list\/\">map(function, iterable,&#8230;)<\/a><\/td><td>Return an iterator that contains the results of when applying the <code>function<\/code> to every item of <code>iterable<\/code>.<\/td><\/tr><tr><td><a href=\"https:\/\/www.pythontutorial.net\/python-built-in-functions\/python-max\/\">max(iterable,\u00a0[,\u00a0key,\u00a0default])<\/a><br>max(arg1, arg2, *args, [,key])<br><\/td><td>Return the largest item in an iterable or the largest of two or more arguments.<\/td><\/tr><tr><td><a href=\"https:\/\/www.pythontutorial.net\/python-built-in-functions\/python-min\/\">min(iterable,\u00a0[,\u00a0key,\u00a0default])<\/a><br>min(arg1, arg2, *args, [,key])<\/td><td>Return the smallest item in an iterable or the smallest of two or more arguments<\/td><\/tr><tr><td><a href=\"https:\/\/www.pythontutorial.net\/python-built-in-functions\/python-next\/\">next(iterator[,&nbsp;default])<\/a><\/td><td>Return the next item from the <code>iterator<\/code>.<\/td><\/tr><tr><td>object()<\/td><td>Return the <code>object<\/code> that is the base object of all other objects<\/td><\/tr><tr><td>oct(x)<\/td><td>Convert an integer to an octal string prefixed with <code>0o<\/code><\/td><\/tr><tr><td>open()<\/td><td>Open a file and return a file object.<\/td><\/tr><tr><td>ord(c)<\/td><td>Return an integer that represents the Unicode code point of the character <code>c<\/code>.<\/td><\/tr><tr><td>pow(base, exp[, mod])<\/td><td>Return&nbsp;<code>base<\/code>&nbsp;to the power&nbsp;<code>exp<\/code>. If the mod is available, return the <code>(base**exp) % mod<\/code> . The calculation is more efficient than <code>pow(base, exp) % mod<\/code><\/td><\/tr><tr><td>print()<\/td><td>Print&nbsp;<code>objects<\/code>&nbsp;to the text stream&nbsp;<code>file<\/code>, separated by&nbsp;<code>sep<\/code>&nbsp;and followed by&nbsp;<code>end<\/code>.<\/td><\/tr><tr><td><a href=\"https:\/\/www.pythontutorial.net\/python-oop\/python-properties\/\">property()<\/a><\/td><td>Return a property attribute<\/td><\/tr><tr><td>range(stop)<br>range(start, stop[, step])<\/td><td>Return an immutable sequence object<\/td><\/tr><tr><td><a href=\"https:\/\/www.pythontutorial.net\/python-oop\/python-__repr__\/\">repr(object)<\/a><\/td><td>Return a string that contains the printable representation of an object.<\/td><\/tr><tr><td>reversed(seq)<\/td><td>Return a reverse of a sequence specified by <code>seq<\/code><\/td><\/tr><tr><td><a href=\"https:\/\/www.pythontutorial.net\/advanced-python\/python-rounding\/\">round(number[, ndigits])<\/a><\/td><td>Return&nbsp;the <code>number<\/code>&nbsp;rounded to&nbsp;<code>ndigits<\/code>&nbsp;precision after the decimal point.<\/td><\/tr><tr><td><a href=\"https:\/\/www.pythontutorial.net\/python-basics\/python-set\/\">set([iterable])<\/a><\/td><td>Return a new <code>Set<\/code> object<\/td><\/tr><tr><td><a href=\"https:\/\/www.pythontutorial.net\/python-built-in-functions\/python-setattr\/\">setattr(object, name, value)<\/a><\/td><td>Set the <code>value<\/code> to the <code>name<\/code> attribute of the <code>object<\/code> i.e., <code>object.name = value<\/code><\/td><\/tr><tr><td><a href=\"https:\/\/www.pythontutorial.net\/advanced-python\/python-slicing\/\">slice(start, stop[, step])<\/a><\/td><td>Return a&nbsp;slice&nbsp;object<\/td><\/tr><tr><td><a href=\"https:\/\/www.pythontutorial.net\/python-basics\/python-sorted\/\">sorted()<\/a><\/td><td>Return a sorted list of items from the iterable.<\/td><\/tr><tr><td><a href=\"https:\/\/www.pythontutorial.net\/python-oop\/python-static-methods\/\">@staticmethod<\/a><\/td><td>Transform a method into a static method<\/td><\/tr><tr><td>str()<\/td><td>Return the string version of an object<\/td><\/tr><tr><td>sum(iterable, \/ , start=0)<\/td><td>Return the total of the <code>start<\/code> with all items of an <code>iterable<\/code> from left to right.<\/td><\/tr><tr><td><a href=\"https:\/\/www.pythontutorial.net\/python-oop\/python-super\/\">super(type)<\/a><\/td><td>Return a proxy object that can delegate calls to methods of a parent or sibling class of&nbsp;<code>type<\/code><\/td><\/tr><tr><td><a href=\"https:\/\/www.pythontutorial.net\/python-basics\/python-tuples\/\">tuple([iterable])<\/a><\/td><td>Create a tuple from an iterable<\/td><\/tr><tr><td>type(object)<\/td><td>Return the type of an object<\/td><\/tr><tr><td>vars(object)<\/td><td>Return the&nbsp;<a href=\"https:\/\/docs.python.org\/3\/library\/stdtypes.html#object.__dict__\"><code>__dict__<\/code><\/a>&nbsp;attribute of any object (e.g., a module, a class, an instance,..) with a&nbsp;<a href=\"https:\/\/docs.python.org\/3\/library\/stdtypes.html#object.__dict__\"><code>__dict__<\/code><\/a>&nbsp;attribute.<br><\/td><\/tr><tr><td><a href=\"https:\/\/www.pythontutorial.net\/python-built-in-functions\/python-zip\/\">zip(*iterables, strict=False)<\/a><\/td><td>Iterate over multiple iterables in parallel and make tuples with an item from each iterable.<\/td><\/tr><tr><td>__import__()<\/td><td>The <code>__import__()<\/code> is invoked by the <code><a href=\"https:\/\/www.pythontutorial.net\/python-oop\/python-import\/\">import<\/a><\/code> statement to change its effects. It is not recommended to use the <code>__import__()<\/code> function directly.<\/td><\/tr><\/tbody><\/table><\/figure>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful ?<\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"1055\"\n\t\t\t\tdata-post-url=\"https:\/\/www.pythontutorial.net\/python-built-in-functions\/\"\n\t\t\t\tdata-post-title=\"Python Built-in Functions\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"1055\"\n\t\t\t\tdata-post-url=\"https:\/\/www.pythontutorial.net\/python-built-in-functions\/\"\n\t\t\t\tdata-post-title=\"Python Built-in Functions\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\t\t\t<input type=\"button\" name=\"wth-submit\" class=\"wth-btn wth-btn-submit\" id=\"wth-submit\" \/>\n\t\t\t<input type=\"button\" class=\"wth-btn wth-btn-cancel\" value=\"Cancel\" \/>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>This page provides you with Python built-in functions and types for reference.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":12,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1055","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/pages\/1055","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/comments?post=1055"}],"version-history":[{"count":0,"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/pages\/1055\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/media?parent=1055"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}