{"id":75329,"date":"2020-01-21T10:44:30","date_gmt":"2020-01-21T05:14:30","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=75329"},"modified":"2020-01-21T10:44:30","modified_gmt":"2020-01-21T05:14:30","slug":"python-built-in-functions","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/python-built-in-functions\/","title":{"rendered":"Python Built-in Functions &#8211; Learn the functions with syntax and examples"},"content":{"rendered":"<p>In this article, we are going to see all the <strong>pre-defined functions<\/strong> that are available in Python.<\/p>\n<p>You have already used some of the Python <strong>built-in functions<\/strong>, for example, the <strong>print() function<\/strong> is used to <strong>output<\/strong> a <strong>string<\/strong> on the <strong>console<\/strong>. As of now, the latest version of <strong>Python 3.8 has 69 built-in functions<\/strong>.<\/p>\n<p>We will go through each of them.<\/p>\n<h3>Python Built-in Functions<\/h3>\n<p>The Python interpreter contains a <strong>number of functions<\/strong> that are always <strong>available<\/strong> to use anywhere in the program. These functions are <strong>built-in<\/strong> functions.<\/p>\n<p>Below is the list of all the available built-in functions in <strong>chronological order<\/strong>.<\/p>\n<h3>List of Python Built-in Functions<\/h3>\n<table class=\"tv-table-center\">\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400\">abs()<\/span><\/td>\n<td><span style=\"font-weight: 400\">enumerate()<\/span><\/td>\n<td><span style=\"font-weight: 400\">iter()<\/span><\/td>\n<td><span style=\"font-weight: 400\">reversed()<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">all()<\/span><\/td>\n<td><span style=\"font-weight: 400\">eval()<\/span><\/td>\n<td><span style=\"font-weight: 400\">len()<\/span><\/td>\n<td><span style=\"font-weight: 400\">round()<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">any()<\/span><\/td>\n<td><span style=\"font-weight: 400\">exec()<\/span><\/td>\n<td><span style=\"font-weight: 400\">list()<\/span><\/td>\n<td><span style=\"font-weight: 400\">set()<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">ascii()<\/span><\/td>\n<td><span style=\"font-weight: 400\">filter()<\/span><\/td>\n<td><span style=\"font-weight: 400\">locals()<\/span><\/td>\n<td><span style=\"font-weight: 400\">setattr()<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">bin()<\/span><\/td>\n<td><span style=\"font-weight: 400\">float()<\/span><\/td>\n<td><span style=\"font-weight: 400\">map()<\/span><\/td>\n<td><span style=\"font-weight: 400\">slice()<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">bool()<\/span><\/td>\n<td><span style=\"font-weight: 400\">format()<\/span><\/td>\n<td><span style=\"font-weight: 400\">max()<\/span><\/td>\n<td><span style=\"font-weight: 400\">sorted()<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">breakpoint()<\/span><\/td>\n<td><span style=\"font-weight: 400\">frozenset()<\/span><\/td>\n<td><span style=\"font-weight: 400\">memoryview()<\/span><\/td>\n<td><span style=\"font-weight: 400\">staticmethod()<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">bytearray()<\/span><\/td>\n<td><span style=\"font-weight: 400\">getattr()<\/span><\/td>\n<td><span style=\"font-weight: 400\">min()<\/span><\/td>\n<td><span style=\"font-weight: 400\">str()<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">bytes()<\/span><\/td>\n<td><span style=\"font-weight: 400\">globals()<\/span><\/td>\n<td><span style=\"font-weight: 400\">next()<\/span><\/td>\n<td><span style=\"font-weight: 400\">sum()<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">callable()<\/span><\/td>\n<td><span style=\"font-weight: 400\">hasattr()<\/span><\/td>\n<td><span style=\"font-weight: 400\">object()<\/span><\/td>\n<td><span style=\"font-weight: 400\">super()<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">chr()<\/span><\/td>\n<td><span style=\"font-weight: 400\">hash()<\/span><\/td>\n<td><span style=\"font-weight: 400\">oct()<\/span><\/td>\n<td><span style=\"font-weight: 400\">tuple()<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">classmethod()<\/span><\/td>\n<td><span style=\"font-weight: 400\">hel<\/span><span style=\"font-weight: 400\">p()<\/span><\/td>\n<td><span style=\"font-weight: 400\">op<\/span><span style=\"font-weight: 400\">en()<\/span><\/td>\n<td><span style=\"font-weight: 400\">type()<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">compile()<\/span><\/td>\n<td><span style=\"font-weight: 400\">hex()<\/span><\/td>\n<td><span style=\"font-weight: 400\">ord()<\/span><\/td>\n<td><span style=\"font-weight: 400\">vars()<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">complex()<\/span><\/td>\n<td><span style=\"font-weight: 400\">id()<\/span><\/td>\n<td><span style=\"font-weight: 400\">pow()<\/span><\/td>\n<td><span style=\"font-weight: 400\">zip()<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">delattr()<\/span><\/td>\n<td><span style=\"font-weight: 400\">input()<\/span><\/td>\n<td><span style=\"font-weight: 400\">print()<\/span><\/td>\n<td><span style=\"font-weight: 400\">__import__()<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">dict()<\/span><\/td>\n<td><span style=\"font-weight: 400\">int()<\/span><\/td>\n<td><span style=\"font-weight: 400\">property()<\/span><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">dir()<\/span><\/td>\n<td><span style=\"font-weight: 400\">isinstance()<\/span><\/td>\n<td><span style=\"font-weight: 400\">range()<\/span><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">divmod()<\/span><\/td>\n<td><span style=\"font-weight: 400\">issubclass()<\/span><\/td>\n<td><span style=\"font-weight: 400\">repr()<\/span><\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Here is a detailed explanation of built-in functions in <strong>Python<\/strong>.<\/p>\n<h3>1. abs(x)<\/h3>\n<p>The <strong>abs() function<\/strong> returns the <strong>absolute value<\/strong> of the number which is the <strong>distance of a point<\/strong> from <strong>zero index<\/strong>. The <strong>argument x<\/strong> can be an <strong>integer<\/strong> or a <strong>floating-point value<\/strong>. In case of complex numbers, their <strong>magnitude<\/strong> is <strong>returned<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">print( abs(4) )\nprint( abs(-2.5) )\nprint( abs(3j + 2) )<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">4<br \/>\n2.5<br \/>\n3.6055512754639896<\/div>\n<h3>2. all(<em>iterable<\/em>)<\/h3>\n<p>The<strong> all() function<\/strong> takes an <strong>iterable<\/strong> container as an <strong>argument<\/strong> and returns <strong>True<\/strong> when <strong>all elements<\/strong> of the iterable are <strong>True(or is empty)<\/strong> <strong>otherwise<\/strong> it returns <strong>False<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">print( all([]))\nprint( all([True, True, False]))\nprint( all({1,3,5,2}))<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">True<br \/>\nFalse<br \/>\nTrue<\/div>\n<h3>3. any(<em>iterable<\/em>)<\/h3>\n<p>The <strong>any() function<\/strong> takes an <strong>iterable<\/strong> container as an <strong>argument<\/strong> and returns <strong>True<\/strong> when <strong>one of the elements<\/strong> inside the iterable container is <strong>True<\/strong>, <strong>otherwise<\/strong>, it returns <strong>False<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">print( any([]) )\nprint( any([False, False, True, 1, 3]) )\nprint( any({10,20,30,40}) )<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">False<br \/>\nTrue<br \/>\nTrue<\/div>\n<h3>4. ascii(object )<\/h3>\n<p>The <strong>ascii() function<\/strong> returns a <strong>printable representation<\/strong> of the <strong>object<\/strong>. It escapes the <strong>non-ASCII<\/strong> characters in the <strong>string<\/strong>.<\/p>\n<p>The string returned by <strong>ascii()<\/strong> is similar to the<strong> repr() function<\/strong> in Python2.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">ascii(2020)\nascii(\u2018a\u2019)\nascii(\u2018Hello \\n World\u2019)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">\u20182020\u2019<br \/>\n\u201c\u2018a\u2019\u201d<br \/>\n&#8220;&#8216;Hello \\\\n World'&#8221;<\/div>\n<h3>5. bin(x)<\/h3>\n<p>The function<strong> bin()<\/strong> will convert an <strong>integer<\/strong> into its <strong>binary representation<\/strong> in <strong>string format<\/strong>.<\/p>\n<p><strong>Binary numbers<\/strong> are <strong>prefixed<\/strong> with <strong>\u20180b\u2019<\/strong>. It only takes <strong>integer numbers<\/strong> and giving a <strong>string<\/strong> or a <strong>float<\/strong> <strong>value<\/strong> to the function will result in an <strong>error<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">bin(12)\nbin(-12)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">&#8216;0b1100&#8217;<br \/>\n&#8216;-0b1100&#8217;<\/div>\n<h3>6. bool([x])<\/h3>\n<p>The<strong> bool()<\/strong> function returns a <strong>True<\/strong> or <strong>False<\/strong> by converting the argument into a <strong>boolean value<\/strong>. It returns <strong>True<\/strong> when the <strong>argument passed<\/strong> is <strong>True<\/strong> otherwise <strong>empty<\/strong> <strong>containers<\/strong> and <strong>False<\/strong> value will <strong>return False<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">bool(False)\nbool([])\nbool(20)\nbool({1,2,4})<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">False<br \/>\nFalse<br \/>\nTrue<br \/>\nTrue<\/div>\n<h3>7. breakpoint(*args, **kws)<\/h3>\n<p>The <strong>breakpoint()<\/strong> function is introduced from <strong>Python 3.7<\/strong> and it helps in <strong>debugging<\/strong>.<\/p>\n<p>For example, when you use <strong>pdb<\/strong> <strong>debugger<\/strong> then you <strong>call<\/strong> the <strong>pdb.set_trace()<\/strong> in your <strong>program code<\/strong>. Then for a machine that has <strong>web-pdb debugger<\/strong> will have to <strong>change<\/strong> the <strong>code<\/strong> to <strong>web-pdb.set_trace()<\/strong> method.<\/p>\n<p>This becomes an <strong>overhead<\/strong> and for that, we have the <strong>breakpoint()<\/strong> method which allows us to write <strong>loosely coupled debugging code<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">msg = \u201cHi\u201d\nbreakpoint()<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">&gt;<br \/>\nc:\\users\\Techvidvan\\appdata\\local\\programs\\python\\python37-32\\bp.py(4)&lt;module&gt;()<br \/>\n-&gt; print(msg)<br \/>\n(Pdb) msg<br \/>\n&#8216;Hi&#8217;<br \/>\n(Pdb)<\/div>\n<h3>8. bytearray([source[, encoding[, errors]]])<\/h3>\n<p>It returns a <strong>mutable version<\/strong> of <strong>bytes array<\/strong> of integers between<strong> 0-256<\/strong>.<\/p>\n<ul>\n<li>If an <strong>integer<\/strong> is passed, then it will return us an array of that size with <strong>null bytes<\/strong>.<\/li>\n<li>If a <strong>string<\/strong> is passed, then it is necessary to provide <strong>encoding<\/strong> in the second argument.<\/li>\n<\/ul>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">bytearray(4)\nbytearray('abc','utf-8')\nbytearray([1,2,3])<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">bytearray(b&#8217;\\x00\\x00\\x00\\x00&#8242;)<br \/>\nbytearray(b&#8217;abc&#8217;)<br \/>\nbytearray(b&#8217;\\x01\\x02\\x03&#8242;)<\/div>\n<h3>9. bytes([source[, encoding[, errors]]])<\/h3>\n<p>The<strong> byte()<\/strong> function is similar to the<strong> bytearray()<\/strong> function. The only difference is that <strong>bytes() returns<\/strong> an <strong>immutable object<\/strong>. We <strong>cannot change elements<\/strong> of a bytes function.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">bytes(3)\nbytes([3,2,1])<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">b&#8217;\\x00\\x00\\x00&#8242;<br \/>\nb&#8217;\\x03\\x02\\x01&#8242;<\/div>\n<h3>10. callable(Object)<\/h3>\n<p>The <strong>callable function<\/strong> tells us whether an <strong>object<\/strong> is <strong>callable<\/strong> or <strong>not<\/strong>. It returns <strong>True<\/strong> when the argument passed is <strong>callable<\/strong> otherwise it returns <strong>False<\/strong>.<\/p>\n<p><strong>User-defined<\/strong> and all the <strong>built-in<\/strong> <strong>functions<\/strong> are <strong>callable<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">callable(print)\ncallable([1,2,3])\ncallable(abs)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">True<br \/>\nFalse<br \/>\nTrue<\/div>\n<h3>11. chr(i)<\/h3>\n<p>The function <strong>chr()<\/strong> is an <strong>inverse<\/strong> of <strong>ord()<\/strong> function. It takes <strong>unicode<\/strong> <strong>code<\/strong> point as an <strong>argument<\/strong> and <strong>returns<\/strong> the <strong>string representation<\/strong> of the <strong>character<\/strong>.<\/p>\n<p>The <strong>input range<\/strong> is from <strong>0<\/strong> to<strong> 1,114,111<\/strong>. Outside of this range, it will raise an <strong>error<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">chr(65)\nchr(120)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">\u2018A\u2019<br \/>\n\u2018x\u2019<\/div>\n<h3>12. @classmethod()<\/h3>\n<p>The <strong>@classmethod()<\/strong> is a <strong>decorator<\/strong> that is used to <strong>create class methods<\/strong> that will be <strong>passed<\/strong> on all the <strong>objects<\/strong> just like self is <strong>passed<\/strong>.<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">@classmethod()\ndef func(cls, args...):\n  ...<\/pre>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">class Person:\n\n    @classmethod\n    def display(cls):\n        print(\"Person's age is 42\")\n\n\nPerson.display()<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">Person\u2019s age is 42<\/div>\n<h3>13. compile(source, filename, mode)<\/h3>\n<p>The <strong>compile()<\/strong> functions <strong>compiles<\/strong> the <strong>source code<\/strong> into an <strong>executable object<\/strong>. The object can be <strong>executed<\/strong> by using <strong>exec()<\/strong> or <strong>eval()<\/strong> <strong>functions<\/strong>.<\/p>\n<p>The first parameter is the <strong>source code<\/strong>, second is the <strong>filename<\/strong> and the third parameter is the <strong>mode<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">exec(compile('num1=10;num2=20;print(num1+num2);','', 'exec'))<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">30<\/div>\n<h3>14. complex([real[, imag]])<\/h3>\n<p>The <strong>complex()<\/strong> function <strong>returns<\/strong> or <strong>converts<\/strong> a <strong>number<\/strong> into a <strong>complex number<\/strong>.<\/p>\n<p>The <strong>first argument<\/strong> is the <strong>real part<\/strong> of the complex number and the <strong>second argument(optional)<\/strong> is the <strong>imaginary part<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">complex(1,2)\ncomplex(5.5)\ncomplex(3+7j)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">(1+2j)<br \/>\n(5.5+0j)<br \/>\n(3+7j)<\/div>\n<h3>15. delattr(object, name)<\/h3>\n<p>The <strong>delattr() function<\/strong> is used to <strong>delete<\/strong> an <strong>attribute<\/strong> of an <strong>object<\/strong>. It takes <strong>two arguments<\/strong>, the object from which you want to <strong>delete<\/strong> and the <strong>attribute name<\/strong> that you want to <strong>delete<\/strong>.<\/p>\n<p>You can only delete the attribute when you have <strong>permission<\/strong> for it.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">class Car:\n  color = \u2018Blue\u2019\n\nc = Car()\nprint(c.color)\ndelattr(c, \u2018color\u2019)\nprint(c.color)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">Blue<br \/>\nTraceback (most recent call last):<br \/>\n<b>\u00a0\u00a0<\/b>File &#8220;C:\/Users\/Techvidvan\/AppData\/Local\/Programs\/Python\/Python37-32\/bp.py&#8221;, line 6, in &lt;module&gt;<br \/>\n<b>\u00a0\u00a0\u00a0\u00a0<\/b>delattr(c, &#8216;color&#8217;)<br \/>\nAttributeError: color<\/div>\n<h3>16. dict()<\/h3>\n<p>The <strong>dict()<\/strong> function <strong>returns<\/strong> or <strong>creates<\/strong> a new <strong>dictionary<\/strong> which is useful in <strong>mapping values<\/strong>. It takes an <strong>iterable<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">Numbers1 = dict(a=1, b=2, c=3, d=4)\nNumbers2 = dict([(\u2018a\u2019, 1), (\u2018b\u2019: 2), (\u2018c\u2019:3), (\u2018d\u2019:4) ])\nprint(Numbers1)\nprint(Numbers2)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">{\u2018a\u2019 : 1, \u2018b\u2019: 2, \u2018c\u2019:3, \u2018d\u2019:4 }<br \/>\n{\u2018a\u2019 : 1, \u2018b\u2019: 2, \u2018c\u2019:3, \u2018d\u2019:4 }<\/div>\n<h3>17. dir([object])<\/h3>\n<p>The <strong>dir()<\/strong> object returns a <strong>list of all the names<\/strong> of the current <strong>local scope<\/strong> if <strong>no argument<\/strong> is <strong>passed<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">Variable1 = 10\nVariable2 = \u2018Hey\u2019\ndir()<\/pre>\n<p><strong>Output: <\/strong><\/p>\n<div class=\"code-output\">[&#8216;Variable1&#8217;, &#8216;Variable2&#8217;, &#8216;__annotations__&#8217;, &#8216;__builtins__&#8217;, &#8216;__doc__&#8217;, &#8216;__loader__&#8217;, &#8216;__name__&#8217;, &#8216;__package__&#8217;, &#8216;__spec__&#8217;]<\/div>\n<p>When we pass an <strong>object<\/strong> as an <strong>argument<\/strong> then it will return a <strong>list<\/strong> of all the <strong>valid attribute<\/strong> <strong>names<\/strong> of that <strong>object<\/strong>.<\/p>\n<p>Let\u2019s see the attributes of a <strong>string<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">dir(str)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">[&#8216;__add__&#8217;, &#8216;__class__&#8217;, &#8216;__contains__&#8217;, &#8216;__delattr__&#8217;, &#8216;__dir__&#8217;, &#8216;__doc__&#8217;, &#8216;__eq__&#8217;, &#8216;__ge__&#8217;,&#8217;__format__&#8217;, &#8216;__getattribute__&#8217;, &#8216;__getitem__&#8217;, &#8216;__getnewargs__&#8217;, &#8216;__gt__&#8217;, &#8216;__hash__&#8217;, &#8216;__init__&#8217;, &#8216;__init_subclass__&#8217;, &#8216;__iter__&#8217;, &#8216;__le__&#8217;, &#8216;__len__&#8217;, &#8216;__lt__&#8217;, &#8216;__mod__&#8217;, &#8216;__mul__&#8217;, &#8216;__ne__&#8217;, &#8216;__new__&#8217;, &#8216;__reduce__&#8217;, &#8216;__repr__&#8217;, &#8216;__reduce_ex__&#8217;, &#8216;__rmod__&#8217;, &#8216;__rmul__&#8217;, &#8216;__setattr__&#8217;, &#8216;__sizeof__&#8217;, &#8216;__str__&#8217;, &#8216;__subclasshook__&#8217;, &#8216;capitalize&#8217;, &#8216;casefold&#8217;, &#8216;center&#8217;, &#8216;count&#8217;, &#8216;encode&#8217;, &#8216;endswith&#8217;, &#8216;expandtabs&#8217;, &#8216;find&#8217;, &#8216;format&#8217;, &#8216;format_map&#8217;, &#8216;index&#8217;, &#8216;isalnum&#8217;, &#8216;isdecimal&#8217;, &#8216;isalpha&#8217;, &#8216;isdigit&#8217;, &#8216;isidentifier&#8217;, &#8216;islower&#8217;, &#8216;isnumeric&#8217;, &#8216;isprintable&#8217;, &#8216;isspace&#8217;, &#8216;istitle&#8217;, &#8216;isupper&#8217;, &#8216;join&#8217;, &#8216;lstrip&#8217;, &#8216;ljust&#8217;, &#8216;lower&#8217;, &#8216;maketrans&#8217;, &#8216;partition&#8217;, &#8216;replace&#8217;, &#8216;rfind&#8217;, &#8216;rindex&#8217;, &#8216;rjust&#8217;, &#8216;rpartition&#8217;, &#8216;rsplit&#8217;, &#8216;rstrip&#8217;, &#8216;split&#8217;, &#8216;splitlines&#8217;, &#8216;startswith&#8217;, &#8216;strip&#8217;, &#8216;swapcase&#8217;, &#8216;title&#8217;, &#8216;translate&#8217;, &#8216;upper&#8217;, &#8216;zfill&#8217;]<\/div>\n<h3>18. divmod(a,b)<\/h3>\n<p>The function <strong>divmod()<\/strong> takes <strong>two integer<\/strong> or <strong>float numbers<\/strong> as <strong>arguments<\/strong> and then <strong>returns<\/strong> a <strong>tuple<\/strong> whose <strong>first element<\/strong> is the <strong>quotient<\/strong> and <strong>second element<\/strong> is <strong>remainder<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">divmod(20,2)\ndivmod(48,5)\ndivmod(11,2.5)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">(10, 0)<br \/>\n(9, 3)<br \/>\n(4.0, 1.0)<\/div>\n<h3>19. enumerate(iterable, start=0)<\/h3>\n<p>The function returns us an <strong>enumerate object<\/strong> which is used in <strong>loops<\/strong> to <strong>iterate<\/strong> over <strong>iterable objects<\/strong>. It is useful when we want to have a <strong>counter<\/strong> to <strong>calculate something<\/strong>.<\/p>\n<p>The <strong>numbers start<\/strong> from <strong>zero <\/strong>if you want to start with <strong>another number<\/strong> then you can <strong>specify<\/strong> that in the <strong>second argument<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">for i, countryin enumerate([\u2018USA\u2019, \u2018UK\u2019, \u2018NYC\u2019, \u2018TKY\u2019 ]):\n  print(i, country)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">0 USA<br \/>\n1 UK<br \/>\n2 NYC<br \/>\n3 TKY<\/div>\n<h3>20. eval()<\/h3>\n<p>The<strong> eval()<\/strong> function <strong>evaluates<\/strong> a <strong>Python expression<\/strong> that is <strong>passed<\/strong> in a <strong>string<\/strong>. It <strong>parses<\/strong> into a <strong>Python expression<\/strong> and then the <strong>function<\/strong> <strong>evaluates it<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">x=5\neval(\u201810&lt;20\u2019)\neval(\u2018x+ 10\u2019)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">True<br \/>\n15<\/div>\n<h3>21. exec()<\/h3>\n<p>The <strong>exec()<\/strong> function is used to <strong>execute<\/strong> or <strong>run a Python code dynamically<\/strong>. We can write Python code in a <strong>string<\/strong> and <strong>pass<\/strong> it as an argument to the<strong> exec() function<\/strong>. It will parse the <strong>string<\/strong> and <strong>execute<\/strong> the <strong>Python code<\/strong> inside it.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">exec(\u2018print(\u201cHello\u201d)\u2019)\nexec('a=20;b=30; print(a*b)')<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">Hello<br \/>\n600<\/div>\n<h3>22. filter(function, iterable)<\/h3>\n<p>The <strong>filter<\/strong> <strong>function<\/strong> is used to <strong>filter out the data<\/strong>. It does that by iterating on the <strong>second iterable<\/strong> <strong>argument<\/strong> and the <strong>first argument<\/strong> is a function that decides <strong>how we will filter<\/strong> the <strong>elements<\/strong>. This is mostly used with <strong>lambda expressions<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">list(filter(lambda x:x&gt;5 ,[1,2,3,4,5,6,8,10]))<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">[6,8,10]<\/div>\n<p>Here we used a <strong>lambda function<\/strong> in which we want the <strong>elements greater than 5<\/strong> and the <strong>list<\/strong> is filtered out the elements <strong>less than<\/strong> or <strong>equal<\/strong> to 5.<\/p>\n<h3>23. float([x])<\/h3>\n<p>The <strong>float <\/strong>functions <strong>returns<\/strong> or <strong>convert<\/strong> the argument into a <strong>floating-point<\/strong> value if it is <strong>compatible<\/strong>. We can convert <strong>integers<\/strong> and <strong>strings<\/strong> that only contain <strong>digits<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">float(45)\nfloat(\u201812\u2019)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">45.0<br \/>\n12.0<\/div>\n<p>A <strong>complex number<\/strong> or a <strong>string<\/strong> with other characters like <strong>alphabets<\/strong> will raise an <strong>error<\/strong>.<\/p>\n<h3>24. format(value[, format_spec])<\/h3>\n<p>The <strong>format()<\/strong> function is similar to the <strong>format method<\/strong> in <strong>strings<\/strong>. It is used to <strong>modify<\/strong> a value according to a <strong>specific format<\/strong>.<\/p>\n<p>The <strong>first argument<\/strong> is the value that needs to be <strong>formatted<\/strong> and the <strong>second argument<\/strong> is the specifier of how <strong>value<\/strong> is <strong>specified<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">#format decimal number into binary value\nformat( 24, \u201cb\u201d )\n\n#format a float value to have two decimal digits.\nformat(123.456, \u201c0.2f\u201d )<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">&#8216;11000&#8217;<br \/>\n\u2018123.46\u2019<\/div>\n<h3>25. frozenset([iterable])<\/h3>\n<p>The<strong> frozenset()<\/strong> function takes an <strong>iterable<\/strong> as an <strong>argument<\/strong> and <strong>converts<\/strong> it into an <strong>immutable set<\/strong>.<\/p>\n<p>Sets are <strong>mutable<\/strong> by <strong>default<\/strong>. If we want the <strong>same properties<\/strong> of <strong>set<\/strong> but in an <strong>immutable object<\/strong> then we use <strong>frozenset<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">frozenset({1,2,3,4})\nfrozenset([30, 20, 10])\nfrozenset((1, 2.5, 8.5, 4))<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">frozenset({1, 2, 3, 4, 5})<br \/>\nfrozenset({10, 20, 30})<br \/>\nfrozenset({8.5, 1, 2.5, 4})<\/div>\n<h3>26. getattr(object, name)<\/h3>\n<p>The <strong>getattr()<\/strong> function is <strong>used<\/strong> to get the <strong>value<\/strong> of an <strong>object\u2019s attribute<\/strong>.<\/p>\n<p>The <strong>first argument<\/strong> is the <strong>object<\/strong> from which you want the <strong>value<\/strong> and the <strong>second argument<\/strong> is a <strong>string<\/strong> that represents the <strong>name<\/strong> of the <strong>attribute<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">class Car:\n  color = \u2018Blue\u2019\n\nc = Car()\nprint( getattr(c, \u2018color\u2019) )<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">Blue<\/div>\n<h3>27. globals()<\/h3>\n<p>The function returns a <strong>dictionary<\/strong> in which all the global objects are <strong>accessible<\/strong> in the <strong>current scope<\/strong> or <strong>module<\/strong>.<\/p>\n<p>Let\u2019s create a <strong>list<\/strong> in <strong>global scope<\/strong> and see the <strong>dictionary<\/strong> of <strong>objects<\/strong> in the <strong>global scope<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">list1=[1,2,3,4]\nglobals()<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">{&#8216;__name__&#8217;: &#8216;__main__&#8217;, &#8216;__doc__&#8217;: None, &#8216;__package__&#8217;: None, &#8216;__loader__&#8217;: &lt;class &#8216;_frozen_importlib.BuiltinImporter&#8217;&gt;, &#8216;__spec__&#8217;: None, &#8216;__annotations__&#8217;: {}, &#8216;__builtins__&#8217;: &lt;module &#8216;builtins&#8217; (built-in)&gt;, &#8216;Car&#8217;: &lt;class &#8216;__main__.Car&#8217;&gt;, &#8216;c&#8217;: &lt;__main__.Car object at 0x03A79208&gt;, &#8216;list1&#8217;: [1, 2, 3, 4]}<\/div>\n<h3>28. hasattr(object, name)<\/h3>\n<p>This function is also <strong>similar<\/strong> to the <strong>getattr()<\/strong> function instead it checks if the <strong>object<\/strong> contains the <strong>specified attribute<\/strong> or not. It returns a <strong>boolean value<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">class Car:\n  color= \u201cGreen\u201d\n\nc= Car()\nprint(hasattr(c, \u201ccolor\u201d))\nprint(hasattr(c, \u201cprice\u201d))<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">True<br \/>\nFalse<\/div>\n<h3>29. hash(object)<\/h3>\n<p>In Python, everything is an object, <strong>numbers<\/strong>, <strong>strings<\/strong>, etc. all are object.<\/p>\n<p>The <strong>hashable objects<\/strong> are <strong>mapped<\/strong> with an <strong>integer value<\/strong> in <strong>Python<\/strong>. The function<strong> hash()<\/strong> <strong>returns<\/strong> us the hash of the <strong>specified object<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">print( hash(45) )\nprint( hash(\u201chello\u201d) )\nprint( hash(94387593420) )\nprint( hash(True )\nprint(hash(2.5))<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">45<br \/>\n-1010369850<br \/>\n2045796599<br \/>\n1<br \/>\n1073741826<\/div>\n<h3>30. help([object])<\/h3>\n<p><strong>Python<\/strong> has an <strong>inbuilt help system<\/strong> which you can use to see details about any <strong>module<\/strong>, <strong>method, object, keyword, symbol,<\/strong> etc.<\/p>\n<p>Let\u2019s see details about the <strong>string object<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">help(str)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">class str(object)<br \/>\n| str(object=&#8221;) -&gt; str<br \/>\n| str(bytes_or_buffer[, encoding[, errors]]) -&gt; str<br \/>\n|<br \/>\n| Create a new string object from the given object. If encoding or<br \/>\n| errors is specified, then the object must expose a data buffer<br \/>\n| that will be decoded using the given encoding and error handler.<br \/>\n| Otherwise, returns the result of object.__str__() (if defined)<br \/>\n| or repr(object).<br \/>\n| encoding defaults to sys.getdefaultencoding().<br \/>\n| errors defaults to &#8216;strict&#8217;.<br \/>\n|<br \/>\n| Methods defined here:<br \/>\n|<br \/>\n| __add__(self, value, \/)<br \/>\n| <b>\u00a0\u00a0\u00a0\u00a0\u00a0<\/b>Return self+value.<br \/>\n|<br \/>\n| __contains__(self, key, \/)<br \/>\n| <b>\u00a0\u00a0\u00a0\u00a0\u00a0<\/b>Return key in self.<br \/>\n|<br \/>\n| __eq__(self, value, \/)<br \/>\n| <b>\u00a0\u00a0\u00a0\u00a0\u00a0<\/b>Return self==value.<br \/>\n|<br \/>\n| __format__(self, format_spec, \/)<br \/>\n| <b>\u00a0\u00a0\u00a0\u00a0\u00a0<\/b>Return a formatted version of the string as described by format_spec.<br \/>\n|<br \/>\n| __ge__(self, value, \/)<br \/>\n&#8212; More &#8212;<\/div>\n<h3>31. hex(x)<\/h3>\n<p>The <strong>hex()<\/strong> function <strong>converts<\/strong> or <strong>returns<\/strong> the <strong>string representation<\/strong> of the <strong>hexadecimal<\/strong> value of the <strong>number<\/strong>. It takes only <strong>integer number<\/strong> as an <strong>argument<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">hex(123)\nhex(-12)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">&#8216;0x7b&#8217;<br \/>\n&#8216;-0xc&#8217;<\/div>\n<h3>32. id(object)<\/h3>\n<p>The <strong>id() function<\/strong> takes an <strong>object<\/strong> as an <strong>argument<\/strong> and <strong>returns<\/strong> the <strong>identity<\/strong> of the <strong>object<\/strong>. The id is <strong>unique<\/strong> and <strong>constant<\/strong> for each object.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">id(131)\nid(\u201cHello\u201d)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">1933365200<br \/>\n81300384<\/div>\n<p><strong>Two objects<\/strong> with the <strong>same value<\/strong> will have the <strong>same identity<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">name = \u201cTechVidvan\u201d\nperson = \u201cTechVidvan\u201d\nprint( id(name) == id(person) )<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">True<\/div>\n<h3>33. input()<\/h3>\n<p>The Python has an <strong>inbuilt function<\/strong> for taking <strong>input<\/strong> from the <strong>user<\/strong>. The <strong>input()<\/strong> function <strong>reads<\/strong> a <strong>string<\/strong> from the <strong>user<\/strong>, which we can <strong>store<\/strong> in a <strong>variable<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">msg = input(\u201c--&gt;\u201d)\nprint(msg)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">&#8211;&gt;Input as a string<br \/>\n\u2018Input as a string\u2019<\/div>\n<p>The function only takes a <strong>string<\/strong>, if we want an <strong>integer value<\/strong> from the user then we have to use <strong>typecasting<\/strong>.<\/p>\n<p>We can achieve this by using <strong>int() function<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">num = int( input(\u201cEnter number : \u201d ))\ntype(num)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">Enter number : 342<br \/>\n&lt;class \u2018int\u2019 &gt;<\/div>\n<h3>34. int([x])<\/h3>\n<p>The <strong>int() <\/strong>function <strong>returns<\/strong> or <strong>converts<\/strong> a <strong>compatible number<\/strong> or <strong>string<\/strong> into an <strong>integer<\/strong>. A <strong>string<\/strong> containing only <strong>numbers<\/strong> or a <strong>float<\/strong> <strong>value<\/strong> can easily be <strong>converted<\/strong> into <strong>integer<\/strong> using this <strong>function<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">int(10.2345)\nint(\u201812020\u2019)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">10<br \/>\n12020<\/div>\n<h3>35. isinstance(object, classinfo)<\/h3>\n<p>The function <strong>isinstance()<\/strong> checks whether the <strong>object argument<\/strong> is an <strong>instance<\/strong> of the class given in the <strong>second argument<\/strong>, it returns a <strong>boolean value<\/strong>.<\/p>\n<p>We can check this for <strong>built-in classes<\/strong> and also <strong>user-defined classes<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">isinstance(\u201cString object\u201d, str)\nisinstance( 2.5, int)\n\nclass Peep():\n  msg=\u201dHey\u201d\np = Peep()\nisinstance( p, Peep)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">True<br \/>\nFalse<br \/>\nTrue<\/div>\n<h3>36. issubclass(class, classinfo)<\/h3>\n<p>This function checks whether a <strong>class (first argument)<\/strong> is a <strong>subclass<\/strong> of the class in <strong>second argument<\/strong>. It will return <strong>True<\/strong> when there is a <strong>direct<\/strong> or an <strong>indirect<\/strong> <strong>subclass relation<\/strong> between the <strong>classes<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">class A:\n  pass\n\nclass B(A):\n  pass\n\nissubclass(B, A)\nissubclass(A, B)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">True<br \/>\nFalse<\/div>\n<h3>37. iter(object)<\/h3>\n<p>The <strong>inbuilt<\/strong> function<strong> iter()<\/strong> is used to <strong>return<\/strong> an <strong>iterator object<\/strong> that we can use to <strong>iterate over the elements<\/strong> in the <strong>object<\/strong>. This is mostly used in a <strong>for loop<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">nums= [2,4,6,8,10,12]\nfor num in iter( nums):\n  print(num)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">2<br \/>\n4<br \/>\n6<br \/>\n8<br \/>\n10<br \/>\n12<\/div>\n<h3>38. len(s)<\/h3>\n<p>The <strong>len()<\/strong> function takes an <strong>argument<\/strong> which can be <strong>either <\/strong>a<strong> sequence(string, list, tuple, etc)<\/strong> or a <strong>collection(dictionary, set, etc)<\/strong> and returns the <strong>number of elements<\/strong> present <strong>inside<\/strong> them.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">len([1,2,3,4,5])\nlen({10,20})\nlen(\u201cGive me food!\u201d)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">5<br \/>\n2<br \/>\n13<\/div>\n<h3>39. list()<\/h3>\n<p>The<strong> list()<\/strong> function <strong>returns<\/strong> or <strong>creates<\/strong> a <strong>new<\/strong> <strong>list<\/strong>. It takes <strong>iterable<\/strong> like <strong>sets<\/strong>, <strong>tuples<\/strong>, etc. and <strong>converts<\/strong> them into the <strong>list<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">list(\u201cHello\u201d)\nlist({1,3,4,5,3,2})\nlist((\u201crose\u201d, \u201chibiscus\u201d, \u201clily\u201d))<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">[&#8216;H&#8217;, &#8216;e&#8217;, &#8216;l&#8217;, &#8216;l&#8217;, &#8216;o&#8217;]<br \/>\n[1, 2, 3, 4, 5]<br \/>\n[&#8216;rose&#8217;, &#8216;hibiscus&#8217;, &#8216;lily&#8217;]<\/div>\n<h3>40. locals()<\/h3>\n<p>The<strong> locals()<\/strong> in-built method is similar to the <strong>globals()<\/strong> method which we saw earlier. It <strong>returns<\/strong> a <strong>dictionary<\/strong> of the <strong>current local symbol table<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">locals()<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">{&#8216;__name__&#8217;: &#8216;__main__&#8217;, &#8216;__doc__&#8217;: None, &#8216;__package__&#8217;: None, &#8216;__loader__&#8217;: &lt;class &#8216;_frozen_importlib.BuiltinImporter&#8217;&gt;, &#8216;__spec__&#8217;: None, &#8216;__annotations__&#8217;: {}, &#8216;__builtins__&#8217;: &lt;module &#8216;builtins&#8217; (built-in)&gt;, &#8216;var1&#8217;: 3, &#8216;var2&#8217;: 3, &#8216;name&#8217;: &#8216;Shrangi&#8217;, &#8216;person&#8217;: &#8216;Shrangi&#8217;, &#8216;msg&#8217;: &#8216;Input as a string&#8217;, &#8216;num&#8217;: 342, &#8216;Car&#8217;: &lt;class &#8216;__main__.Car&#8217;&gt;, &#8216;c&#8217;: &lt;__main__.Car object at 0x04D891C0&gt;, &#8216;A&#8217;: &lt;class &#8216;__main__.A&#8217;&gt;, &#8216;B&#8217;: &lt;class &#8216;__main__.B&#8217;&gt;}<\/div>\n<h3>41. map(function, iterable)<\/h3>\n<p>The <strong>map()<\/strong> function is used to <strong>map each element<\/strong> of an <strong>iterable element<\/strong> to a <strong>function<\/strong>. It is similar to the<strong> filter()<\/strong> method that we saw before. It is <strong>useful<\/strong> in <strong>modifying<\/strong> each <strong>element<\/strong> of an iterable according to a <strong>function<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">list(map(lambda x:x+10, [1,2,3,4,5] ))<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">[11, 12, 13, 14, 15]<\/div>\n<h3>42. max(iterable)<\/h3>\n<p>The <strong>max()<\/strong> function is <strong>self-explanatory<\/strong>, it takes an <strong>iterable container<\/strong> or <strong>sequence<\/strong> as an argument and returns the <strong>maximum value<\/strong> from the <strong>list<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">max([1,3,5,7,123, 435,-2678,65])\n\nmax( {-20, 80, 20, 30} )<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">435<br \/>\n80<\/div>\n<h3>43. memoryview(object)<\/h3>\n<p>The <strong>memoryview()<\/strong> function takes a <strong>bytes object<\/strong> as <strong>argument<\/strong> and <strong>returns<\/strong> a view of the <strong>memory<\/strong> and it\u2019s a <strong>safe<\/strong> way to expose <strong>buffer protocol<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">var = bytes(6)\nmemoryview(var)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">&lt;memory at 0x04C60328&gt;<\/div>\n<h3>44. min(iterable)<\/h3>\n<p>The <strong>min() function<\/strong> is also similar to the<strong> max() functions<\/strong>. It returns the <strong>minimum value<\/strong> from a <strong>group<\/strong> of items in an <strong>iterable<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">min([7,4,2,1])\n\nmin({-6, -10, 20, 30})<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">1<br \/>\n-10<\/div>\n<h3>45. next(iterator)<\/h3>\n<p>The <strong>next() function<\/strong> is used to get the <strong>next item<\/strong> from the <strong>iterator object<\/strong>. Every time we call the <strong>next() method<\/strong> the iterator points to the <strong>next element<\/strong>.<\/p>\n<p>When there are <strong>no next element<\/strong> present, then the function raises a <strong>StopIteration error<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">myIterator = iter([10,20,30])\nnext(myIterator)\nnext(myIterator)\nnext(myIterator)\nnext(myIterator)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">10<br \/>\n20<br \/>\n30<br \/>\nTraceback (most recent call last):<br \/>\n<span style=\"font-weight: 400\">\u00a0\u00a0<\/span>File &#8220;&lt;stdin&gt;&#8221;, line 1, in &lt;module&gt;<br \/>\nStopIteration<\/div>\n<h3>46. object()<\/h3>\n<p>The <strong>object() method<\/strong> does not take any arguments and it <strong>returns<\/strong> a <strong>featureless<\/strong> <strong>object<\/strong>. It is the <strong>base<\/strong> for all <strong>classes<\/strong> and it contains methods that are <strong>common<\/strong> to all the Python objects.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">obj = object()\ntype(obj)\ndir(obj)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">&lt;class \u2018object\u2019&gt;<br \/>\n[&#8216;__class__&#8217;, &#8216;__delattr__&#8217;, &#8216;__dir__&#8217;, &#8216;__doc__&#8217;, &#8216;__eq__&#8217;, &#8216;__format__&#8217;, &#8216;__ge__&#8217;, &#8216;__getattribute__&#8217;, &#8216;__gt__&#8217;, &#8216;__hash__&#8217;, &#8216;__init__&#8217;, &#8216;__init_subclass__&#8217;, &#8216;__le__&#8217;, &#8216;__lt__&#8217;, &#8216;__ne__&#8217;, &#8216;__new__&#8217;, &#8216;__reduce__&#8217;, &#8216;__reduce_ex__&#8217;, &#8216;__repr__&#8217;, &#8216;__setattr__&#8217;, &#8216;__sizeof__&#8217;, &#8216;__str__&#8217;, &#8216;__subclasshook__&#8217;]<\/div>\n<h3>47. oct(x)<\/h3>\n<p>The <strong>oct()<\/strong> function <strong>converts<\/strong> or <strong>returns<\/strong> an<strong> octal representation<\/strong> of a <strong>number<\/strong>.<\/p>\n<p>Octal numbers are <strong>prefixed<\/strong> with <strong>\u201c0o\u201d<\/strong>. It only takes an <strong>integer value<\/strong> and <strong>returns<\/strong> its <strong>octal value<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">oct(10)\noct(-200)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">\u20180o12\u2019<br \/>\n\u2018-0o310\u2019<\/div>\n<h3>48. open(file, mode=\u2019r\u2019)<\/h3>\n<p>The <strong>open()<\/strong> function is used in <strong>working<\/strong> with <strong>files<\/strong>. It can open <strong>any file<\/strong>.<\/p>\n<p>The <strong>first argument<\/strong> is the <strong>file path<\/strong> and the <strong>second argument<\/strong> is the <strong>mode<\/strong> by which we open the file, <strong>for<\/strong> <strong>example<\/strong>, <strong>read<\/strong>, <strong>write<\/strong>, <strong>append<\/strong>, etc. we use characters <strong>\u2018r\u2019<\/strong>,<strong> \u2018w\u2019<\/strong> and <strong>\u2018a\u2019<\/strong> respectively to <strong>represent<\/strong> these <strong>modes<\/strong>.<\/p>\n<p>The default mode is <strong>read mode<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">f=open('E:\\\\techvidvan\/test.txt')\nprint(f)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">&lt;_io.TextIOWrapper name=&#8217;E:\\\\techvidvan\/test.txt&#8217; mode=&#8217;r&#8217; encoding=&#8217;cp1252&#8242;&gt;<\/div>\n<p>To read the contents of the file we use the <strong>read() method<\/strong> on the file.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">contents = f.read()\nprint(contents)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">Hello World!<\/div>\n<h3>49. ord(c)<\/h3>\n<p>The <strong>ord()<\/strong> method takes a <strong>Unicode character<\/strong> as an <strong>argument<\/strong> and <strong>returns<\/strong> an <strong>integer representation<\/strong> of the <strong>character<\/strong>. It is the <strong>opposite<\/strong> of the <strong>chr()<\/strong> function.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">ord(\u2018a\u2019)\nord(\u2018$\u2019)\nord(\u20189\u2019)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">97<br \/>\n36<br \/>\n57<\/div>\n<h3>50. pow(base, exp)<\/h3>\n<p>The <strong>pow()<\/strong> function is used for <strong>calculating<\/strong> the <strong>mathematical power<\/strong> of a number. This function returns the <strong>base<\/strong> to the <strong>power of exp<\/strong>.<\/p>\n<p>For example<strong> pow(a,b)<\/strong> will return a to the <strong>power of b<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">pow(2, 4)\npow(5.5, 2 )\npow(8,-1)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">16<br \/>\n30.25<br \/>\n0.125<\/div>\n<h3>51. print(*objects, sep=\u201d \u201d, end=\u201d\\n\u201d )<\/h3>\n<p>You have already used this function thousands of times.<\/p>\n<p>The <strong>print()<\/strong> function <strong>prints<\/strong> the objects to the <strong>text stream file<\/strong>. It <strong>separates<\/strong> the object by <strong>space<\/strong> by <strong>default<\/strong> and in the end, it appends a <strong>newline<\/strong> by <strong>default<\/strong>. We can change this by specifying <strong>different arguments<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">print(\u201cHello!\u201d)\nprint(1,2,3,4, sep=\u201d-\u201d)\nprint(\u201c$$\u201d, end=\u201d\u201d);\nprint(\u201c@@\u201d)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">Hello!<br \/>\n1-2-3-4<br \/>\n$$@@<\/div>\n<h3>52. property()<\/h3>\n<p>The <strong>property() method<\/strong> is used to <strong>return a property<\/strong> attribute from the given <strong>getter<\/strong>, <strong>setter<\/strong>, or <strong>deleter<\/strong>.<\/p>\n<p>The <strong>syntax<\/strong> of property() method is &#8211;<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">property(fget=None, fset=None, fdel=None, doc=None)<\/pre>\n<ul>\n<li>The fget is a function used to get attribute value.<\/li>\n<li>The fset is a function for setting an attribute value.<\/li>\n<li>The fdel is a function for deleting an attribute.<\/li>\n<li>The doc is a string used for docstrings.<\/li>\n<\/ul>\n<h3>53. range(start, stop, step)<\/h3>\n<p>The<strong> range() function<\/strong> is used to <strong>generate<\/strong> a <strong>sequence of numbers<\/strong> from a <strong>starting range<\/strong> to the <strong>stop number<\/strong>. It is useful to <strong>iterate<\/strong> over a <strong>range of elements<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">for i in range(5,10):\n  print(i)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">5<br \/>\n6<br \/>\n7<br \/>\n8<br \/>\n9<\/div>\n<h3>54. repr()<\/h3>\n<p>The <strong>repr()<\/strong> function is used to <strong>return <\/strong>a <strong>printable version<\/strong> of the <strong>Python objects<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">repr(\u201cHey\u201d)\na = 5.5\nrepr(a)\nrepr({1,2,3,4})<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">\u201c\u2018Hey\u2019\u201d<br \/>\n\u20185.5\u2019<br \/>\n&#8216;{1, 2, 3, 4}&#8217;<\/div>\n<h3>55. reversed(seq)<\/h3>\n<p>The<strong> reversed()<\/strong> function takes a <strong>sequence<\/strong> as an <strong>argument<\/strong> and <strong>returns <\/strong>a<strong> reverse iterator<\/strong> to the <strong>sequence<\/strong>. It is used when we want to iterate the <strong>elements backward<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">for i in reversed([1,2,4,6,8]):\n  print(i)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">8<br \/>\n6<br \/>\n4<br \/>\n2<br \/>\n1<\/div>\n<h3>56. round(numbers [,digits])<\/h3>\n<p>The<strong> round()<\/strong> function round offs a number to specified<strong> n-digits. <\/strong>If the <strong>digits<\/strong> are <strong>not specified<\/strong> then it round offs to a <strong>natural number<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">round(3.5)\nround(3.2)\nround(1.666666, 2 )<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">4<br \/>\n3<br \/>\n1.67<\/div>\n<h3>57. set([iterable])<\/h3>\n<p><strong>Set<\/strong> is a <strong>built-in<\/strong> class in <strong>Python<\/strong>.<\/p>\n<p>The set() function takes an <strong>iterable<\/strong> as an <strong>argument<\/strong> and <strong>returns<\/strong> a set object of that <strong>iterable<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">set([1,3,3,5,6,5])\nset((10,20,50,20))<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">{1, 3, 5, 6}<br \/>\n{10,20,50}<\/div>\n<h3>58. setattr(object, name, value)<\/h3>\n<p>We have seen <strong>getattr()<\/strong> and<strong> hasattr()<\/strong>.<\/p>\n<p>Now the <strong>setattr()<\/strong> function is used to set a <strong>value<\/strong> of an <strong>attribute<\/strong>. We can set a <strong>new attribute<\/strong> or <strong>update<\/strong> an attribute if the class <strong>allows<\/strong> us to <strong>modify<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">class Student:\n  pass\n\ns= Student()\nsetattr(s, \u201cname\u201d, \u201cRambo\u201d)\ns.name<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">Rambo<\/div>\n<h3>59. slice(start, stop [,step])<\/h3>\n<p>The <strong>slice()<\/strong> function returns a <strong>slice object<\/strong> just like a <strong>range<\/strong>. We can use the slice object to slice a <strong>sequence<\/strong> like <strong>lists<\/strong>, <strong>strings<\/strong>, etc.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">s1= slice(4)\ns2= slice(1,6,2)\nprint(s1)\nprint(s2)\n\nprint(\u201c123456789\u201d[s1])\nprint(\u201c123456789\u201d[s2])<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">slice(None, 4, None)<br \/>\nslice(1,6,2)<br \/>\n1234<br \/>\n246<\/div>\n<h3>60. sorted(iterable)<\/h3>\n<p>The <strong>sorted()<\/strong> function sorts the given <strong>iterable<\/strong> and <strong>returns<\/strong> a list of all the elements in <strong>ascending order<\/strong> by <strong>default<\/strong>. It will sort a <strong>list<\/strong>, <strong>string<\/strong>, <strong>sets<\/strong>, etc and will always return a list.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">sorted([7,5,3,2,1])\nsorted(\u201cHello\u201d)\nsorted({1,2,3,4,5}, reverse=True)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">[1, 2, 3, 5, 7]<br \/>\n[&#8216;H&#8217;, &#8216;e&#8217;, &#8216;l&#8217;, &#8216;l&#8217;, &#8216;o&#8217;]<br \/>\n[5, 4, 3, 2, 1]<\/div>\n<h3>61. @staticmethod()<\/h3>\n<p>This is a decorator which is used to <strong>transform<\/strong> a method into a <strong>static method<\/strong>. A static method can be <strong>directly called<\/strong> with the <strong>class name<\/strong> without <strong>creating any instance<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">class Letter:\n    @staticmethod\n    def msg():\n        print(\"static method\")\n\nLetter.msg()<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">Static method<\/div>\n<h3>62. str(object)<\/h3>\n<p>The <strong>str() function<\/strong> is used to <strong>convert<\/strong> an <strong>object<\/strong> into a <strong>string<\/strong>. <strong>str<\/strong> is the <strong>built-in<\/strong> class for <strong>strings<\/strong>. It can be used in <strong>type conversion<\/strong> of numbers into <strong>strings<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">str()\nstr(125)\nstr(\u201cHello\u201d)\nstr({1,10,60})<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">\u2018\u2019<br \/>\n\u2018125\u2019<br \/>\n\u2018Hello\u2019<br \/>\n&#8216;{1, 10, 60}&#8217;<\/div>\n<h3>63. sum(iterable)<\/h3>\n<p>The function<strong> sum()<\/strong> is also <strong>self-explanatory<\/strong>. It takes an <strong>iterable<\/strong> <strong>collection<\/strong> or <strong>sequence<\/strong> as an <strong>argument<\/strong> and <strong>returns<\/strong> the <strong>sum of all the elements<\/strong>.<\/p>\n<p>The elements should be <strong>only numbers<\/strong> else it will not be able to <strong>add elements<\/strong> and <strong>throw errors<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">sum([1,2,3,4,5])\nsum((10,30,10))\nsum([1, 4.5, 8.6, 100])<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">15<br \/>\n50<br \/>\n114.1<\/div>\n<h3>64. super()<\/h3>\n<p>The <strong>super()<\/strong> method is used to <strong>return<\/strong> a <strong>proxy<\/strong> <strong>object<\/strong> that refers to the <strong>parent class<\/strong>. By using the super() method we can access the <strong>parent class methods<\/strong> or <strong>attributes<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">class A:\n    def __init__(self):\n        print(\"Class A\")\n\nclass B(A):\n    def __init__(self):\n        super().__init__()\n        print(\"Class B\")\n\nb = B()<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">Class A<br \/>\nClass B<\/div>\n<h3>65. tuple([iterable])<\/h3>\n<p><strong>Tuple<\/strong> is an <strong>immutable sequence<\/strong> of <strong>elements<\/strong>. The <strong>tuple()<\/strong> function is used to <strong>create<\/strong> or <strong>convert<\/strong> other sequences like <strong>lists<\/strong>, <strong>strings,<\/strong> etc into tuples.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">tuple([1,2,3,4,5])\ntuple(\u201cTechvidvan\u201d)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">(1, 2, 3, 4, 5)<br \/>\n(&#8216;T&#8217;, &#8216;e&#8217;, &#8216;c&#8217;, &#8216;h&#8217;, &#8216;v&#8217;, &#8216;i&#8217;, &#8216;d&#8217;, &#8216;v&#8217;, &#8216;a&#8217;, &#8216;n&#8217;)<\/div>\n<h3>66. type()<\/h3>\n<p>The <strong>type()<\/strong> function <strong>returns<\/strong> the <strong>type<\/strong> of the <strong>Python objects<\/strong> or the <strong>class<\/strong> of the <strong>Python objects<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">type(\u201cTech\u201d)\ntype(3.5)\ntype([])\ntype({1,2,3})<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">&lt;class &#8216;str&#8217;&gt;<br \/>\n&lt;class &#8216;float&#8217;&gt;<br \/>\n&lt;class &#8216;list&#8217;&gt;<br \/>\n&lt;class &#8216;set&#8217;&gt;<\/div>\n<h3>67. vars([object])<\/h3>\n<p>The<strong> vars()<\/strong> function returns the<strong> __dict__ attribute<\/strong> of a <strong>module<\/strong>, <strong>class<\/strong>, <strong>instance<\/strong>, or any <strong>Python object. <\/strong>If arguments are <strong>not passed<\/strong> then it is similar to the <strong>locals() function<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">vars(tuple)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">mappingproxy({&#8216;__repr__&#8217;: &lt;slot wrapper &#8216;__repr__&#8217; of &#8216;tuple&#8217; objects&gt;, &#8216;__hash__&#8217;: &lt;slot wrapper &#8216;__hash__&#8217; of &#8216;tuple&#8217; objects&gt;, &#8216;__getattribute__&#8217;: &lt;slot wrapper &#8216;__getattribute__&#8217; of &#8216;tuple&#8217; objects&gt;, &#8216;__lt__&#8217;: &lt;slot wrapper &#8216;__lt__&#8217; of &#8216;tuple&#8217; objects&gt;, &#8216;__le__&#8217;: &lt;slot wrapper &#8216;__le__&#8217; of &#8216;tuple&#8217; objects&gt;, &#8216;__eq__&#8217;: &lt;slot wrapper &#8216;__eq__&#8217; of &#8216;tuple&#8217; objects&gt;, &#8216;__ne__&#8217;: &lt;slot wrapper &#8216;__ne__&#8217; of &#8216;tuple&#8217; objects&gt;, &#8216;__gt__&#8217;: &lt;slot wrapper &#8216;__gt__&#8217; of &#8216;tuple&#8217; objects&gt;, &#8216;__ge__&#8217;: &lt;slot wrapper &#8216;__ge__&#8217; of &#8216;tuple&#8217; objects&gt;, &#8216;__iter__&#8217;: &lt;slot wrapper &#8216;__iter__&#8217; of &#8216;tuple&#8217; objects&gt;, &#8216;__len__&#8217;: &lt;slot wrapper &#8216;__len__&#8217; of &#8216;tuple&#8217; objects&gt;, &#8216;__getitem__&#8217;: &lt;slot wrapper &#8216;__getitem__&#8217; of &#8216;tuple&#8217; objects&gt;, &#8216;__add__&#8217;: &lt;slot wrapper &#8216;__add__&#8217; of &#8216;tuple&#8217; objects&gt;, &#8216;__mul__&#8217;: &lt;slot wrapper &#8216;__mul__&#8217; of &#8216;tuple&#8217; objects&gt;, &#8216;__rmul__&#8217;: &lt;slot wrapper &#8216;__rmul__&#8217; of &#8216;tuple&#8217; objects&gt;, &#8216;__contains__&#8217;: &lt;slot wrapper &#8216;__contains__&#8217; of &#8216;tuple&#8217; objects&gt;, &#8216;__new__&#8217;: &lt;method &#8216;__getnewargs__&#8217; of &#8216;tuple&#8217; objects&gt;&lt;built-in method __new__ of type object at 0x733B8588&gt;, &#8216;__getnewargs__&#8217;: , &#8216;index&#8217;: &lt;method &#8216;index&#8217; of &#8216;tuple&#8217; objects&gt;, &#8216;count&#8217;: &lt;method &#8216;count&#8217; of &#8216;tuple&#8217; objects&gt;, &#8216;__doc__&#8217;: \u201cBuilt-in immutable sequence.\\n\\nIf no argument is given, the constructor returns an empty tuple.\\nIf iterable is specified the tuple is initialized from iterable&#8217;s items.\\n\\nIf the argument is a tuple, the return value is the same object.&#8221;})<\/div>\n<h3>68. zip(*iterables)<\/h3>\n<p>The <strong>zip function<\/strong> returns us <strong>iterators<\/strong> of <strong>tuples<\/strong>. It can take any number of <strong>iterables<\/strong> and packs their <strong>same index positions<\/strong> into <strong>tuples<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">for i in zip([10,20,30,40],[1,2,3],[1,2,3,4,5]):\n  print(i)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">(10, 1, 1)<br \/>\n(20, 2, 2)<br \/>\n(30, 3, 3)<\/div>\n<h3>69. __import__(name)<\/h3>\n<p>This is an <strong>advanced function<\/strong> that is not used in everyday programming.<\/p>\n<p>Whenever we use an import statement like &#8211; <strong>import numpy, i<\/strong>t calls <strong>the __import__() function<\/strong> automatically which <strong>imports<\/strong> the <strong>statements<\/strong>.<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">__import__(name, globals, locals, fromlist, level)<\/pre>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">__import__('math', globals(), locals(), [], 0)<\/pre>\n<p>This statement is equivalent to <strong>\u2018import math\u2019<\/strong>. This function is useful when we want to <strong>import<\/strong> a <strong>module<\/strong> during <strong>runtime<\/strong>.<\/p>\n<h3>Summary<\/h3>\n<p>This article is a bit lengthy and you should congratulate yourself for making this far.<\/p>\n<p>We have discussed all the <strong>69 Python built-in functions<\/strong>. The built-in functions are available to use anywhere in the <strong>Python programme<\/strong>.<\/p>\n<p>You can use TechVidvan&#8217;s Python built-in functions article as a reference when you want to quickly grasp information about a function.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article, we are going to see all the pre-defined functions that are available in Python. You have already used some of the Python built-in functions, for example, the print() function is used&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":75590,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1053],"tags":[1331,1332,1333,1334,1335,1336,1337,1338],"class_list":["post-75329","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-classmethod","tag-binx","tag-boolx","tag-built-in-functions-in-python","tag-dict","tag-eval","tag-python-built-in-functions-list","tag-python-built-in-functions"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Python Built-in Functions - Learn the functions with syntax and examples - TechVidvan<\/title>\n<meta name=\"description\" content=\"Python built-in functions - Check out 69 in-built functions of Python with syntax and examples such as abs(x), zip(*iterables), bool([x]), etc.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techvidvan.com\/tutorials\/python-built-in-functions\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Built-in Functions - Learn the functions with syntax and examples - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"Python built-in functions - Check out 69 in-built functions of Python with syntax and examples such as abs(x), zip(*iterables), bool([x]), etc.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/python-built-in-functions\/\" \/>\n<meta property=\"og:site_name\" content=\"TechVidvan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/TechVidvan\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-01-21T05:14:30+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/01\/python-built-in-functions.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"802\" \/>\n\t<meta property=\"og:image:height\" content=\"420\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:site\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"19 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python Built-in Functions - Learn the functions with syntax and examples - TechVidvan","description":"Python built-in functions - Check out 69 in-built functions of Python with syntax and examples such as abs(x), zip(*iterables), bool([x]), etc.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/techvidvan.com\/tutorials\/python-built-in-functions\/","og_locale":"en_US","og_type":"article","og_title":"Python Built-in Functions - Learn the functions with syntax and examples - TechVidvan","og_description":"Python built-in functions - Check out 69 in-built functions of Python with syntax and examples such as abs(x), zip(*iterables), bool([x]), etc.","og_url":"https:\/\/techvidvan.com\/tutorials\/python-built-in-functions\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2020-01-21T05:14:30+00:00","og_image":[{"width":802,"height":420,"url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/01\/python-built-in-functions.jpg","type":"image\/jpeg"}],"author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@vidvantech","twitter_site":"@vidvantech","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"19 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/python-built-in-functions\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-built-in-functions\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"Python Built-in Functions &#8211; Learn the functions with syntax and examples","datePublished":"2020-01-21T05:14:30+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-built-in-functions\/"},"wordCount":3770,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-built-in-functions\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/01\/python-built-in-functions.jpg","keywords":["@classmethod()","bin(x)","bool([x])","Built-In functions in Python","dict()","eval()","python built in functions list","Python Built-In functions"],"articleSection":["Python Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/python-built-in-functions\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/python-built-in-functions\/","url":"https:\/\/techvidvan.com\/tutorials\/python-built-in-functions\/","name":"Python Built-in Functions - Learn the functions with syntax and examples - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-built-in-functions\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-built-in-functions\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/01\/python-built-in-functions.jpg","datePublished":"2020-01-21T05:14:30+00:00","description":"Python built-in functions - Check out 69 in-built functions of Python with syntax and examples such as abs(x), zip(*iterables), bool([x]), etc.","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-built-in-functions\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/python-built-in-functions\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/python-built-in-functions\/#primaryimage","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/01\/python-built-in-functions.jpg","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/01\/python-built-in-functions.jpg","width":802,"height":420,"caption":"built-in functions in python"},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/python-built-in-functions\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Python Built-in Functions &#8211; Learn the functions with syntax and examples"}]},{"@type":"WebSite","@id":"https:\/\/techvidvan.com\/tutorials\/#website","url":"https:\/\/techvidvan.com\/tutorials\/","name":"TechVidvan Blogs","description":"","publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techvidvan.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techvidvan.com\/tutorials\/#organization","name":"TechVidvan","url":"https:\/\/techvidvan.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","width":200,"height":50,"caption":"TechVidvan"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/TechVidvan\/","https:\/\/x.com\/vidvantech"]},{"@type":"Person","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22","name":"TechVidvan Team","description":"The TechVidvan Team delivers practical, beginner-friendly tutorials on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our experts are here to help you upskill and excel in today\u2019s tech industry."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/75329","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/comments?post=75329"}],"version-history":[{"count":0,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/75329\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media\/75590"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=75329"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=75329"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=75329"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}