{"id":7464,"date":"2024-03-19T06:49:12","date_gmt":"2024-03-19T06:49:12","guid":{"rendered":"https:\/\/www.skillvertex.com\/blog\/?p=7464"},"modified":"2024-03-19T06:49:12","modified_gmt":"2024-03-19T06:49:12","slug":"python-built-in-functions","status":"publish","type":"post","link":"https:\/\/www.skillvertex.com\/blog\/python-built-in-functions\/","title":{"rendered":"Python Built-in Functions"},"content":{"rendered":"\n<div class=\"wp-block-rank-math-toc-block\" id=\"rank-math-toc\" id=\"rank-math-toc\"><p>Table of Contents<\/p><nav><ul><li ><a href=\"#what-is-python-abs-function\">What is Python abs() Function?<\/a><\/li><li ><a href=\"#what-is-python-all-function\">What is Python all() Function?<\/a><\/li><li ><a href=\"#what-is-the-python-bin-function\">What is the Python bin() Function?<\/a><\/li><li ><a href=\"#what-is-python-bool\">What is Python Bool()<\/a><\/li><li ><a href=\"#what-is-python-bytes\">What is Python bytes()?<\/a><\/li><li ><a href=\"#what-is-the-python-callable-function\">What is the Python callable () Function?<\/a><\/li><li ><a href=\"#what-is-the-python-compile-function\">What is the Python compile() Function?<\/a><\/li><li ><a href=\"#what-is-the-python-exec-function\">What is the Python exec() Function?<\/a><\/li><li ><a href=\"#what-is-the-python-sum-function\">What is the Python sum() Function?<\/a><\/li><li ><a href=\"#what-is-python-any-function\">What is Python any() Function?<\/a><\/li><li ><a href=\"#what-is-python-ascii-function\">What is  Python ASCII () Function?<\/a><\/li><li ><a href=\"#what-is-python-byte-array\">What is Python byte array()?<\/a><\/li><li ><a href=\"#what-is-python-eval-function\">What is Python eval() Function?<\/a><\/li><li ><a href=\"#what-is-python-float\">What is Python float()?<\/a><\/li><li ><a href=\"#what-is-python-format-function\">What is Python Format() Function?<\/a><\/li><li ><a href=\"#what-is-python-frozenset\">What is Python Frozenset()?<\/a><\/li><li ><a href=\"#what-is-the-python-getattr-function\">What is the Python getattr() Function?<\/a><\/li><li ><a href=\"#what-is-the-python-global-function\">What is the Python global() Function?<\/a><\/li><li ><a href=\"#what-is-python-hasattr-function\">What is Python hasattr() Function?<\/a><\/li><li ><a href=\"#python-iter-function\">Python iter() Function?<\/a><\/li><li ><a href=\"#what-is-the-python-len-function\">What is the Python len() Function?<\/a><\/li><li ><a href=\"#what-is-python-list\">What is Python list() ?<\/a><\/li><li ><a href=\"#what-is-python-local-function\">What is Python local() Function?<\/a><\/li><li ><a href=\"#what-is-a-python-map-function\">What is a Python map() Function?<\/a><\/li><li ><a href=\"#what-is-the-python-memory-view-function\">What is the Python memory view() Function?<\/a><\/li><li ><a href=\"#what-is-a-python-object\">What is a Python object()?<\/a><\/li><li ><a href=\"#what-is-the-python-open-function\">What is the Python open() Function?<\/a><\/li><li ><a href=\"#what-is-python-chr-function\">What is Python chr() Function?<\/a><\/li><li ><a href=\"#what-is-the-python-complex-function\">What is the Python complex () function?<\/a><\/li><li ><a href=\"#what-is-the-python-delattr-function\">What is the Python delattr () Function?<\/a><\/li><li ><a href=\"#what-is-the-python-dir-function\">What is the Python dir() Function?<\/a><\/li><li ><a href=\"#what-is-the-python-divmod-function\">What is the Python divmod () Function?<\/a><\/li><li ><a href=\"#what-is-the-python-enumerate-function\">What is the Python enumerate () Function?<\/a><\/li><li ><a href=\"#what-is-python-dict\">What is Python dict?<\/a><\/li><li ><a href=\"#what-is-the-python-filter-function\">What is the Python filter() Function?<\/a><\/li><li ><a href=\"#what-is-a-python-hash-function\">What is a Python hash() Function?<\/a><\/li><li ><a href=\"#what-is-the-python-help-function\">What is the Python help() Function?<\/a><\/li><li ><a href=\"#what-is-python-min-function\">What is Python min() Function?<\/a><\/li><li ><a href=\"#what-is-the-python-set-function\">What is the Python set () Function?<\/a><\/li><li ><a href=\"#what-is-a-python-hex-function\">What is a Python hex() Function?<\/a><\/li><li ><a href=\"#what-is-python-id-function\">What is Python id() Function?<\/a><\/li><li ><a href=\"#what-is-the-python-setattr-function\">What is the Python setattr () Function?<\/a><\/li><li ><a href=\"#what-is-pythons-next-function\">What is Python&#8217;s next() Function?<\/a><\/li><li ><a href=\"#what-is-the-python-input-function\">What is the Python input() Function?<\/a><\/li><li ><a href=\"#what-is-python-int-function\">What is Python int() Function?<\/a><\/li><li ><a href=\"#what-is-a-python-isinstance-function\">What is a Python isinstance () Function?<\/a><\/li><li ><a href=\"#what-is-python-oct-function\">What is Python oct() Function?<\/a><\/li><li ><a href=\"#what-is-the-python-ord-function\">What is the Python ord() Function?<\/a><\/li><li ><a href=\"#what-is-the-python-pow-function\">What is the Python Pow () Function?<\/a><\/li><li ><a href=\"#what-is-the-python-print-function\">What is the Python  Print () Function?<\/a><\/li><li ><a href=\"#what-is-the-python-range-function\">What is the Python range () Function?<\/a><\/li><li ><a href=\"#what-is-the-python-reversed-function\">What is the Python reversed() Function?<\/a><\/li><li ><a href=\"#what-is-a-python-round-function\">What is a Python round Function?<\/a><\/li><li ><a href=\"#what-is-python-issubclass-function\">What is Python issubclass () Function?<\/a><\/li><li ><a href=\"#what-is-python-str\">What is Python str?<\/a><\/li><li ><a href=\"#what-is-the-python-tuple-function\">What is the Python tuple() Function?<\/a><\/li><li ><a href=\"#what-is-python-type-function\">What is Python type() Function?<\/a><\/li><li ><a href=\"#what-is-the-python-vars-function\">What is the  Python vars() Function?<\/a><\/li><li ><a href=\"#what-is-the-python-zip-function\">What is the Python zip() Function?<\/a><\/li><li ><a href=\"#conclusion\">Conclusion<\/a><\/li><li ><a href=\"#python-built-in-functions-faq\">Python Built-in Functions -FAQ<\/a><\/li><\/ul><\/nav><\/div>\n\n\n\n<p>The Python built-in -functions are referred to as the functions where the functionality is pre-defined in<a href=\"https:\/\/www.skillvertex.com\/blog\/which-of-the-following-is-a-bad-python-variable-name\/\" data-type=\"post\" data-id=\"2650\"> Python. <\/a>Whereas, the <a href=\"https:\/\/www.skillvertex.com\/blog\/how-does-a-python-interpreter-works\/\" data-type=\"post\" data-id=\"6895\">Python interpreter <\/a>consists of several functions that will be available for use.  So, these functions are known as Python Built-in Functions. Let us check out this article to learn more about Python Built-in Functions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-python-abs-function\">What is Python abs() Function?<\/h2>\n\n\n\n<p>The Python <strong>abs() <\/strong> function will return the value of a number. Thus, it will take only one argument,  a number where the <a href=\"https:\/\/www.skillvertex.com\/blog\/how-to-pass-an-array-by-value-in-c\/\" data-type=\"post\" data-id=\"2638\">value <\/a>will be returned. This<a href=\"https:\/\/www.skillvertex.com\/blog\/python-positional-arguments\/\" data-type=\"post\" data-id=\"7296\"> argument<\/a> can either be an <a href=\"https:\/\/www.skillvertex.com\/blog\/integer-promotions-in-c\/\" data-type=\"post\" data-id=\"1968\">integer<\/a> or a<a href=\"https:\/\/www.skillvertex.com\/blog\/python-numbers\/\" data-type=\"post\" data-id=\"7023\"> floating-point number.<\/a>  Suppose, if the argument is a complex number, thus, abs() will return their magnitude.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"> Example<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using abs() function\nnumber = -10\nabsolute_value = abs(number)\n\n# Output\nprint(f\"The absolute value of {number} is: {absolute_value}\")\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>The absolute value of -10 is: 10\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-python-all-function\">What is Python all() Function?<\/h2>\n\n\n\n<p>The Python <strong>all() <\/strong>function will accept the iterable object that includes list, and dictionary. Hence, it will return all items when the iterable is<a href=\"https:\/\/www.skillvertex.com\/blog\/python-booleans\/\" data-type=\"post\" data-id=\"7030\"> true<\/a>. But, if it comes false. So, the iterable <a href=\"https:\/\/www.skillvertex.com\/blog\/which-is-not-an-ado-net-dataadapter-object\/\" data-type=\"post\" data-id=\"2225\">object w<\/a>ill become empty and all()  <a href=\"https:\/\/www.skillvertex.com\/blog\/python-functions\/\" data-type=\"post\" data-id=\"7272\">functions<\/a> will be true.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using all() function\nnumbers = &#91;2, 4, 6, 8, 10]\n\n# Check if all numbers are even\nare_all_even = all(num % 2 == 0 for num in numbers)\n\n# Output\nprint(f\"Are all numbers even? {are_all_even}\")\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\nAre all numbers even? True\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-the-python-bin-function\">What is the Python bin() Function?<\/h2>\n\n\n\n<p>The Python <strong>bin()<\/strong> function will operate to return the<a href=\"https:\/\/www.skillvertex.com\/blog\/difference-between-binary-search-and-linear-search\/\" data-type=\"post\" data-id=\"520\"> binary<\/a> representation of a specified integer. So, the<a href=\"https:\/\/www.skillvertex.com\/blog\/what-will-be-the-output-of-the-following-program\/\" data-type=\"post\" data-id=\"3081\"> output<\/a> will begin with the prefix Ob.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using bin() function\ndecimal_number = 10\n\n# Convert decimal_number to binary\nbinary_representation = bin(decimal_number)\n\n# Output\nprint(f\"The binary representation of {decimal_number} is: {binary_representation}\")\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>The binary representation of 10 is: 0b1010\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-python-bool\">What is Python Bool()<\/h2>\n\n\n\n<p><a href=\"https:\/\/www.skillvertex.com\/blog\/python-booleans\/\" data-type=\"post\" data-id=\"7030\">Python<\/a> <strong>bool() <\/strong> will function to convert the value into a boolean such as True or False with the standard truth testing procedure.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using bool() function\nvalue_1 = 42\nvalue_2 = 0\n\n# Convert values to boolean\nbool_value_1 = bool(value_1)\nbool_value_2 = bool(value_2)\n\n# Output\nprint(f\"Boolean value of {value_1}: {bool_value_1}\")\nprint(f\"Boolean value of {value_2}: {bool_value_2}\")\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Boolean value of 42: True\nBoolean value of 0: False\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-python-bytes\">What is Python bytes()?<\/h2>\n\n\n\n<p>The Python <strong>bytes()<\/strong> work to return the bytes object. It is considered an immutable version of the <a href=\"https:\/\/www.skillvertex.com\/blog\/pointer-vs-array-in-c\/\" data-type=\"post\" data-id=\"2733\">byte array()<\/a> function.  Thus, it can make the empty bytes object in the required size.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using bytes() function\nbyte_values = &#91;65, 66, 67, 68]  # ASCII values for 'A', 'B', 'C', 'D'\n\n# Create a bytes object from list of integers\nbyte_sequence = bytes(byte_values)\n\n# Output\nprint(f\"Bytes object: {byte_sequence}\")\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Bytes object: b'ABCD'\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-the-python-callable-function\">What is the Python callable () Function?<\/h2>\n\n\n\n<p>This Python <strong>callable ()<\/strong> method will take only one argument, an object, and then return one of the two values. Whereas, if the output is true then the object will become callable.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using callable() function with x = 4\ndef example_function():\n    print(\"Hello, from the example function!\")\n\nclass ExampleClass:\n    def __call__(self):\n        print(\"Hello, from the __call__ method of ExampleClass!\")\n\n# Create an instance of ExampleClass\nexample_instance = ExampleClass()\n\n# Check if objects are callable\nx = 4  # Setting x to 4\nis_function_callable = callable(example_function)\nis_instance_callable = callable(example_instance)\n\n# Output\nprint(f\"Is example_function callable with x = {x}? {is_function_callable}\")\nprint(f\"Is example_instance callable with x = {x}? {is_instance_callable}\")\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Is example_function callable with x = 4? True\nIs example_instance callable with x = 4? True\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-the-python-compile-function\">What is the Python compile() Function?<\/h2>\n\n\n\n<p>The Python<strong> compile () <\/strong> function will use the <a href=\"https:\/\/www.skillvertex.com\/blog\/which-is-not-part-of-code-technical-review-in-sonarqube\/\" data-type=\"post\" data-id=\"2815\">source code <\/a>as the input and then return the code object. Then, it will be run by the exec() function.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n# Example using compile() function with x = 4\nx = 4\nsource_code = f\"result = x * 2; print('Result:', result)\"\n\n# Compile the source code\ncompiled_code = compile(source_code, filename=\"&lt;string&gt;\", mode=\"exec\")\n\n# Execute the compiled code\nexec(compiled_code)\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Result: 8<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-the-python-exec-function\">What is the Python exec() Function?<\/h2>\n\n\n\n<p>The Python <strong>exec () <\/strong>will work for the dynamic execution of the Python program and will be either a <a href=\"https:\/\/www.skillvertex.com\/blog\/array-of-strings-in-c\/\" data-type=\"post\" data-id=\"2641\">string o<\/a>r an object. Thus, it will accept large blocks of code .<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using exec() function\npython_code = \"\"\"\nx = 4\nresult = x * 3\nprint(f\"The result of x * 3 is: {result}\")\n\"\"\"\n\n# Execute the Python code\nexec(python_code)\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>The result of x * 3 is: 12\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-the-python-sum-function\">What is the Python sum() Function?<\/h2>\n\n\n\n<p>In Python <strong>sum()<\/strong> function will enable us to <a href=\"https:\/\/www.skillvertex.com\/blog\/python-arithmetic-operators\/\" data-type=\"post\" data-id=\"6958\">add<\/a> all the numbers in the list.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using sum() function\nnumbers = &#91;1, 2, 3, 4, 5]\n\n# Calculate the sum of numbers in the list\nresult_sum = sum(numbers)\n\n# Output\nprint(f\"The sum of numbers in the list is: {result_sum}\")\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>The sum of numbers in the list is: 15\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-python-any-function\">What is Python any() Function?<\/h2>\n\n\n\n<p>The Python<strong> any() <\/strong>Function will give the output as true if either the iterable comes true. In other cases, it will come False.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using any() function with I as 2, 4, 8\nI = &#91;2, 4, 8]\n\n# Check if any value in the list is true\nis_any_true = any(I)\n\n# Output\nprint(f\"Is there any true value in the list? {is_any_true}\")\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Is there any true value in the list? True\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-python-ascii-function\">What is  Python ASCII () Function?<\/h2>\n\n\n\n<p>The Python<strong> ASCII <\/strong>() function will return the string and has the printable representation of the object. However, it will ignore the <a href=\"https:\/\/www.skillvertex.com\/blog\/character-arithmetic-in-c-and-c\/\" data-type=\"post\" data-id=\"1876\">non-ASCII characters<\/a> in the string with the \\x, \\u, or \\U escapes.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using ascii() function\ncharacter = '\u20ac'\n\n# Get the ASCII representation of the character\nascii_representation = ascii(character)\n\n# Output\nprint(f\"The ASCII representation of '{character}' is: {ascii_representation}\")\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>The ASCII representation of '\u20ac' is: '\\u20ac'\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-python-byte-array\">What is Python byte array()?<\/h2>\n\n\n\n<p>The Python <strong>byte array(<\/strong>) will return the <a href=\"https:\/\/www.skillvertex.com\/blog\/how-arrays-are-passed-to-functions-in-c-c\/\" data-type=\"post\" data-id=\"2612\">byte array <\/a>output and then turn the objects into the byte array objects.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using bytearray() function\nstring_data = \"Hello, Bytearray!\"\n\n# Convert a string to a bytearray\nbyte_array_data = bytearray(string_data, 'utf-8')\n\n# Output\nprint(f\"The original string: {string_data}\")\nprint(f\"The bytearray representation: {byte_array_data}\")\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>The original string: Hello, Bytearray!\nThe bytearray representation: bytearray(b'Hello, Bytearray!')\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-python-eval-function\">What is Python eval() Function?<\/h2>\n\n\n\n<p>The Python<strong> eval()<\/strong>  function will rephrase the <a href=\"https:\/\/www.skillvertex.com\/blog\/which-of-the-following-is-a-legal-expression-in-sql\/\" data-type=\"post\" data-id=\"1856\">expression<\/a> that is passed on to it and then it will execute the Python code in the Program<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using eval() function\nexpression = \"2 + 3 * 4\"\n\n# Evaluate the expression using eval()\nresult = eval(expression)\n\n# Output\nprint(f\"The result of the expression '{expression}' is: {result}\")\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>The result of the expression '2 + 3 * 4' is: 14<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-python-float\">What is Python float()?<\/h2>\n\n\n\n<p>The Python <strong>float()<\/strong> function will return the floating-point number from a number or string.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using float() function\nnumber_str = \"7.5\"\n\n# Convert the string to a float\nfloat_value = float(number_str)\n\n# Output\nprint(f\"The float representation of '{number_str}' is: {float_value}\")\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>The float representation of '7.5' is: 7.5\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-python-format-function\">What is Python Format() Function?<\/h2>\n\n\n\n<p>The Python F<strong>ormat () <\/strong>function will help us to return the formatted representation of the provided value.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using format() function\nname = \"Alice\"\nage = 25\n\n# Format a string with variables\nformatted_string = \"My name is {} and I am {} years old.\".format(name, age)\n\n# Output\nprint(formatted_string)\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>My name is Alice and I am 25 years old.\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-python-frozenset\">What is Python Frozenset()?<\/h2>\n\n\n\n<p>The Python<strong> frozenset() <\/strong>function will allow us to return the immutable frozen set object that will be initialized with the elements from the given iterable.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using frozenset() function\nset_values = {1, 2, 3, 4, 5}\n\n# Create a frozenset from a set\nfrozen_set = frozenset(set_values)\n\n# Output\nprint(f\"The original set: {set_values}\")\nprint(f\"The frozenset representation: {frozen_set}\")\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>The original set: {1, 2, 3, 4, 5}\nThe frozenset representation: frozenset({1, 2, 3, 4, 5})\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-the-python-getattr-function\">What is the Python getattr() Function?<\/h2>\n\n\n\n<p>The Python <strong>getattr()  <\/strong>will return the value of the named attribute of an object. Hence, if it is not found, then it will return with the default value.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using getattr() function\nclass MyClass:\n    age = 25\n\n# Create an instance of MyClass\nobj = MyClass()\n\n# Use getattr() to get the value of the 'age' attribute\nattribute_value = getattr(obj, 'age', 'default_value')\n\n# Output\nprint(f\"The value of 'age' attribute is: {attribute_value}\")\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>The value of 'age' attribute is: 25\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-the-python-global-function\">What is the Python global() Function?<\/h2>\n\n\n\n<p>The Python <strong>globals()<\/strong> function will operate to return the dictionary of the current global symbol table. The symbol table will be defined as the data structure, and have the required information regarding the program. Thus, it will have the variable names, methods, and classes. <\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using globals() function\nglobal_variable = \"I am a global variable\"\n\ndef print_global_variable():\n    # Access global variable using globals()\n    global_variable_value = globals()&#91;'global_variable']\n    print(f\"Inside the function: {global_variable_value}\")\n\n# Call the function\nprint_global_variable()\n\n# Access global variable directly\ndirect_global_variable = globals()&#91;'global_variable']\nprint(f\"Outside the function: {direct_global_variable}\")\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Inside the function: I am a global variable\nOutside the function: I am a global variable\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-python-hasattr-function\">What is Python hasattr() Function?<\/h2>\n\n\n\n<p>This function will return the true value only if any of the items is true, otherwise it will be false.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using hasattr() function\nclass MyClass:\n    name = \"John\"\n    age = 25\n\n# Create an instance of MyClass\nobj = MyClass()\n\n# Check if the attribute 'name' exists in the object\nhas_name_attribute = hasattr(obj, 'name')\nhas_height_attribute = hasattr(obj, 'height')\n\n# Output\nprint(f\"Does the object have 'name' attribute? {has_name_attribute}\")\nprint(f\"Does the object have 'height' attribute? {has_height_attribute}\")\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Does the object have 'name' attribute? True\nDoes the object have 'height' attribute? False\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"python-iter-function\">Python iter() Function?<\/h2>\n\n\n\n<p>The Python<strong> iter()<\/strong> Function will work to return the iterator object. Thus, it will make the object to \/iterate one element at a time.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using iter() function\nnumbers = &#91;1, 2, 3, 4, 5]\n\n# Create an iterator object from the list\niterator = iter(numbers)\n\n# Output\nprint(\"Using iterator to iterate through the list:\")\nfor num in iterator:\n    print(num)\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Using iterator to iterate through the list:\n1\n2\n3\n4\n5\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-the-python-len-function\">What is the Python len() Function?<\/h2>\n\n\n\n<p>The Python<strong> len()<\/strong> function will work to return the length of the object.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using len() function\nstring_example = \"Hello, Python!\"\nlist_example = &#91;1, 2, 3, 4, 5]\n\n# Get the length of the string\nstring_length = len(string_example)\n\n# Get the length of the list\nlist_length = len(list_example)\n\n# Output\nprint(f\"The length of the string is: {string_length}\")\nprint(f\"The length of the list is: {list_length}\")\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>The length of the string is: 13\nThe length of the list is: 5\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-python-list\">What is Python list() ?<\/h2>\n\n\n\n<p>The Python <strong>list() <\/strong>will make a list in Python.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using list() function\nstring_example = \"Python\"\ntuple_example = (1, 2, 3, 4, 5)\n\n# Convert a string to a list\nstring_as_list = list(string_example)\n\n# Convert a tuple to a list\ntuple_as_list = list(tuple_example)\n\n# Output\nprint(f\"Original string: {string_example}\")\nprint(f\"String as a list: {string_as_list}\")\n\nprint(f\"\\nOriginal tuple: {tuple_example}\")\nprint(f\"Tuple as a list: {tuple_as_list}\")\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Original string: Python\nString as a list: &#91;'P', 'y', 't', 'h', 'o', 'n']\n\nOriginal tuple: (1, 2, 3, 4, 5)\nTuple as a list: &#91;1, 2, 3, 4, 5]\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-python-local-function\">What is Python local() Function?<\/h2>\n\n\n\n<p>The Python <strong>local() <\/strong>method will contain the update and then will return with the dictionary of the current local symbol table. <\/p>\n\n\n\n<p>The symbol table is referred to as a data structure with the necessary information about the program. Additionally, it has variable names, methods, and classes.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example demonstrating local variables and functions\ndef outer_function():\n    outer_variable = \"I am a local variable\"\n\n    def inner_function():\n        inner_variable = \"I am also a local variable\"\n        print(f\"Inside inner_function: {inner_variable}\")\n        print(f\"Inside inner_function accessing outer_variable: {outer_variable}\")\n\n    inner_function()\n\n    # Uncommenting the line below will result in an error, as inner_variable is local to inner_function\n    # print(f\"Outside inner_function accessing inner_variable: {inner_variable}\")\n\n    print(f\"Outside inner_function: {outer_variable}\")\n\n# Uncommenting the line below will result in an error, as outer_variable is local to outer_function\n# print(f\"Outside outer_function: {outer_variable}\")\n\nouter_function()\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Inside inner_function: I am also a local variable\nInside inner_function accessing outer_variable: I am a local variable\nOutside inner_function: I am a local variable\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-a-python-map-function\">What is a Python map() Function?<\/h2>\n\n\n\n<p>The Python <strong>map() <\/strong>function will return the list of results after providing the given function to every item of the iterable.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using map() function\nnumbers = &#91;1, 2, 3, 4, 5]\n\n# Define a function to square a number\ndef square(x):\n    return x ** 2\n\n# Use map() to apply the square function to each element in the list\nsquared_numbers = map(square, numbers)\n\n# Output\nprint(f\"Original numbers: {numbers}\")\nprint(f\"Squared numbers: {list(squared_numbers)}\")\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Original numbers: &#91;1, 2, 3, 4, 5]\nSquared numbers: &#91;1, 4, 9, 16, 25]\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-the-python-memory-view-function\">What is the Python memory view() Function?<\/h2>\n\n\n\n<p>The Python <strong>memory view()<\/strong> function will return the memory view of the given argument.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using memoryview() function\nbyte_array = bytearray(b\"Hello, Memory View!\")\n\n# Create a memory view object\nmemory_view = memoryview(byte_array)\n\n# Output\nprint(f\"Original byte array: {byte_array}\")\nprint(f\"Memory view object: {memory_view}\")\nprint(f\"Characters in memory view: {list(memory_view)}\")\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Original byte array: bytearray(b'Hello, Memory View!')\nMemory view object: &lt;memory at ...&gt;\nCharacters in memory view: &#91;72, 101, 108, 108, 111, 44, 32, 77, 101, 109, 111, 114, 121, 32, 86, 105, 101, 119, 33]\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-a-python-object\">What is a Python object()?<\/h2>\n\n\n\n<p>The Python <strong>object() <\/strong>will return the empty object. Hence, it will act as a base for the classes and carry the built-in properties and the methods that have a default for all the classes.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using object() function\nnew_object = object()\n\n# Output\nprint(f\"Type of new_object: {type(new_object)}\")\nprint(f\"String representation of new_object: {new_object}\")\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Type of new_object: &lt;class 'object'&gt;\nString representation of new_object: &lt;object object at 0x...&gt;\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-the-python-open-function\">What is the Python open() Function?<\/h2>\n\n\n\n<p>The Python <strong>open() <\/strong>Function will function to open the file and will return the corresponding file object.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using open() function\nfile_path = \"example.txt\"\n\n# Writing to a file\nwith open(file_path, \"w\") as file:\n    file.write(\"Hello, Python!\")\n\n# Reading from the file\nwith open(file_path, \"r\") as file:\n    content = file.read()\n\n# Output\nprint(f\"Content of the file '{file_path}': {content}\")\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Content of the file 'example.txt': Hello, Python!\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-python-chr-function\">What is Python chr() Function?<\/h2>\n\n\n\n<p>The Python <strong>chr() <\/strong>Function will operate to get the string that will indicate a character and that contains the Unicode code integer. The function will include the integer argument and will show the error if it goes beyond the specified range.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using chr() function with multiple ASCII codes\nascii_codes = &#91;65, 97, 49, 120]  # ASCII codes for 'A', 'a', '1', 'x'\n\n# Convert ASCII codes to characters\ncharacters = &#91;chr(code) for code in ascii_codes]\n\n# Output\nfor code, char in zip(ascii_codes, characters):\n    print(f\"The character corresponding to ASCII code {code} is: {char}\")\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>The character corresponding to ASCII code 65 is: A\nThe character corresponding to ASCII code 97 is: a\nThe character corresponding to ASCII code 49 is: 1\nThe character corresponding to ASCII code 120 is: x\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-the-python-complex-function\">What is the Python complex () function?<\/h2>\n\n\n\n<p>The Python <strong>complex() <\/strong>function will convert the numbers or strings into the complex number. Hence, this method will have two optional parameters and will return with the complex numbers<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using complex() function\nreal_part = 2.5\nimaginary_part = -1\n\n# Create a complex number\ncomplex_number = complex(real_part, imaginary_part)\n\n# Output\nprint(f\"The complex number is: {complex_number}\")\nprint(f\"Real part: {complex_number.real}\")\nprint(f\"Imaginary part: {complex_number.imag}\")\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>The complex number is: (2.5-1j)\nReal part: 2.5\nImaginary part: -1.0\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-the-python-delattr-function\">What is the Python delattr () Function?<\/h2>\n\n\n\n<p>The Python <strong>delattr() <\/strong>function will delete the attribute from the class. Thus, it will take the two parameters. Initially, it will have an object of the class and secondly, it will have the attribute which is needed to be deleted. Thus, after deleting the attribute, it won&#8217;t be part of the class and will show an error if it has a class object.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using delattr() function\nclass Person:\n    name = \"Alice\"\n    age = 25\n\n# Create an instance of the Person class\nperson = Person()\n\n# Output before using delattr()\nprint(f\"Before using delattr(): {person.__dict__}\")\n\n# Delete the 'age' attribute using delattr()\ndelattr(person, 'age')\n\n# Output after using delattr()\nprint(f\"After using delattr(): {person.__dict__}\")\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Before using delattr(): {'name': 'Alice', 'age': 25}\nAfter using delattr(): {'name': 'Alice'}\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-the-python-dir-function\">What is the Python dir() Function?<\/h2>\n\n\n\n<p>The<strong> dir() <\/strong>function in Python gives you a list of attributes (like variables or methods) that an object has. If an object has a special method called __dir__(), Python will use it to get the list of attributes.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class CustomObject:\n    def __dir__(self):\n        # Custom method to specify attributes\n        return &#91;'custom_attr1', 'custom_attr2']\n\n# Create an instance of CustomObject\ncustom_obj = CustomObject()\n\n# Use dir() to get the list of attributes\nattributes = dir(custom_obj)\n\n# Output\nprint(f\"List of attributes using dir(): {attributes}\")\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>List of attributes using dir(): &#91;'__class__', '__delattr__', '__dict__', '__dir__', '__doc__',\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-the-python-divmod-function\">What is the Python divmod () Function?<\/h2>\n\n\n\n<p>The Python <strong>divmod()<\/strong> function will return with the remainder and the quotient of the two numbers. So, the function will have the two numeric arguments and will get the output as a tuple.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using divmod() function\ndividend = 20\ndivisor = 3\n\n# Get the quotient and remainder using divmod()\nquotient, remainder = divmod(dividend, divisor)\n\n# Output\nprint(f\"Dividend: {dividend}\")\nprint(f\"Divisor: {divisor}\")\nprint(f\"Quotient and remainder: {quotient}, {remainder}\")\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Dividend: 20\nDivisor: 3\nQuotient and remainder: 6, 2\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-the-python-enumerate-function\">What is the Python enumerate () Function?<\/h2>\n\n\n\n<p>The Python<strong> enumerate()<\/strong> function will return with the enumerated object. Hence, it has two parameters initially, the sequence of elements, and the second consists of the start index of the sequence. So, the elements in the sequence will either be through the loop or the next() method. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using enumerate() function\nfruits = &#91;'apple', 'banana', 'orange', 'grape']\n\n# Enumerate the list of fruits starting from index 1\nenumerated_fruits = enumerate(fruits, start=1)\n\n# Output using a loop\nprint(\"Enumerated fruits using a loop:\")\nfor index, fruit in enumerated_fruits:\n    print(f\"Index {index}: {fruit}\")\n\n# Output using list comprehension\nenumerated_fruits = enumerate(fruits, start=1)  # Resetting for list comprehension\nlist_output = &#91;(index, fruit) for index, fruit in enumerated_fruits]\nprint(\"\\nEnumerated fruits using list comprehension:\")\nprint(list_output)\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Enumerated fruits using a loop:\nIndex 1: apple\nIndex 2: banana\nIndex 3: orange\nIndex 4: grape\n\nEnumerated fruits using list comprehension:\n&#91;(1, 'apple'), (2, 'banana'), (3, 'orange'), (4, 'grape')]\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-python-dict\">What is Python dict?<\/h2>\n\n\n\n<p>Python<strong> dict ()<\/strong>acts as a constructor and will make the dictionary.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using dict\nstudent = {\n    'name': 'Alice',\n    'age': 18,\n    'grade': 'A',\n    'subjects': &#91;'Math', 'Science', 'English']\n}\n\n# Output\nprint(\"Student Information:\")\nprint(f\"Name: {student&#91;'name']}\")\nprint(f\"Age: {student&#91;'age']}\")\nprint(f\"Grade: {student&#91;'grade']}\")\nprint(f\"Subjects: {', '.join(student&#91;'subjects'])}\")\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Student Information:\nName: Alice\nAge: 18\nGrade: A\nSubjects: Math, Science, English\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-the-python-filter-function\">What is the Python filter() Function?<\/h2>\n\n\n\n<p>The <strong>filter()<\/strong> function in Python helps us pick specific elements from a group of items. It needs two things to work: a rule (function) and a bunch of things to filter (iterable, like a list). The function checks each item and keeps only the ones that follow the rule.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using filter() function\ndef is_even(num):\n    return num % 2 == 0\n\nnumbers = &#91;1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n\n# Use filter() to get even numbers\neven_numbers = filter(is_even, numbers)\n\n# Output\nprint(\"Original numbers:\", numbers)\nprint(\"Filtered even numbers:\", list(even_numbers))\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Original numbers: &#91;1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\nFiltered even numbers: &#91;2, 4, 6, 8, 10]\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-a-python-hash-function\">What is a Python hash() Function?<\/h2>\n\n\n\n<p>The Python <strong>hash()<\/strong> function will return the value of an object. Hence, this Python will evaluate the hash value with the hash algorithm. So, the hash values are the integers and will function to compare the dictionary keys during the dictionary lookup. <\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using hash() function\nstring_value = \"Hello, Python!\"\ninteger_value = 42\nfloat_value = 3.14\n\n# Get the hash values\nhash_string = hash(string_value)\nhash_integer = hash(integer_value)\nhash_float = hash(float_value)\n\n# Output\nprint(f\"The original string: {string_value}\")\nprint(f\"The hash value for the string: {hash_string}\")\n\nprint(f\"\\nThe original integer: {integer_value}\")\nprint(f\"The hash value for the integer: {hash_integer}\")\n\nprint(f\"\\nThe original float: {float_value}\")\nprint(f\"The hash value for the float: {hash_float}\")\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>The original string: Hello, Python!\nThe hash value for the string: -9077442383218711455\n\nThe original integer: 42\nThe hash value for the integer: 42\n\nThe original float: 3.14\nThe hash value for the float: 1152921504606846979\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-the-python-help-function\">What is the Python help() Function?<\/h2>\n\n\n\n<p>The Python <strong>help() <\/strong>function will work to get help from the related object and will be passed on during the call. However, it will need an optional parameter for returning the help information. Whereas, if there is no help provided, then the  Python help console will be displayed. <\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example function\ndef greet(name):\n    \"\"\"\n    This function greets the person with the given name.\n\n    Parameters:\n    name (str): The name of the person to greet.\n\n    Returns:\n    str: A greeting message.\n    \"\"\"\n    return f\"Hello, {name}! Welcome!\"\n\n# Using the help function to get information about the greet function\nhelp(greet)\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Help on function greet in module __main__:\n\ngreet(name)\n    This function greets the person with the given name.\n\n    Parameters:\n    name (str): The name of the person to greet.\n\n    Returns:\n    str: A greeting message.\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-python-min-function\">What is Python min() Function?<\/h2>\n\n\n\n<p>The Python<strong> min()  <\/strong>will function to receive the smallest element from the elements. Hence, it takes two arguments. Thus, the first consists of the elements that are grouped and the second has a key in it.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using min() function\nnumbers = &#91;5, 3, 8, 2, 7]\n\n# Using min() to find the minimum value in the list\nminimum_value = min(numbers)\n\n# Displaying the result\nprint(\"List of numbers:\", numbers)\nprint(\"Minimum value:\", minimum_value)\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>List of numbers: &#91;5, 3, 8, 2, 7]\nMinimum value: 2\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-the-python-set-function\">What is the Python set () Function?<\/h2>\n\n\n\n<p>The<strong> set ()<\/strong> function is referred to as the built-in class and hence, this function consists of the constructor of this class. So, it will make a new set with the elements that are passed during the call. Hence, it will take an iterable object which will act as an argument and then return as a new set object.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using set() function\nfruits_list = &#91;'apple', 'orange', 'banana', 'apple', 'kiwi']\n\n# Using set() to create a set from the list\nfruits_set = set(fruits_list)\n\n# Displaying the result\nprint(\"List of fruits:\", fruits_list)\nprint(\"Set of fruits:\", fruits_set)\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>List of fruits: &#91;'apple', 'orange', 'banana', 'apple', 'kiwi']\nSet of fruits: {'orange', 'kiwi', 'apple', 'banana'}\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-a-python-hex-function\">What is a Python hex() Function?<\/h2>\n\n\n\n<p>The Python <strong>hex()<\/strong> function will function to create the hex value of the integer argument. So, it will take an integer argument and then return with the integer that will be turned into the hexadecimal string.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using hex() function\ndecimal_number = 255\n\n# Using hex() to convert the decimal number to hexadecimal\nhexadecimal_string = hex(decimal_number)\n\n# Displaying the result\nprint(\"Decimal number:\", decimal_number)\nprint(\"Hexadecimal representation:\", hexadecimal_string)\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Decimal number: 255\nHexadecimal representation: 0xff\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-python-id-function\">What is Python id() Function?<\/h2>\n\n\n\n<p>The Python<strong> id()<\/strong> function will return with the identity of the object. This is referred to as a unique integer.  This function will take an argument as an object and will return the unique integer number that will stand for the identity. <\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using id() function\nvalue1 = 42\nvalue2 = \"Hello, World!\"\n\n# Displaying the identity of the objects\nprint(\"Identity of value1:\", id(value1))\nprint(\"Identity of value2:\", id(value2))\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Identity of value1: 140710617731840\nIdentity of value2: 140710603225904\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-the-python-setattr-function\">What is the Python setattr () Function?<\/h2>\n\n\n\n<p>This Python <strong>set attr () <\/strong>will function to put a value to the object attribute. So, it will take three arguments such as object, string, and arbitrary value, and won&#8217;t return any.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using setattr() function\nclass Person:\n    pass\n\n# Creating an instance of the Person class\nperson_obj = Person()\n\n# Using setattr() to set attributes on the object\nsetattr(person_obj, 'name', 'John Doe')\nsetattr(person_obj, 'age', 30)\n\n# Displaying the attributes\nprint(\"Person's name:\", getattr(person_obj, 'name'))\nprint(\"Person's age:\", getattr(person_obj, 'age'))\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Person's name: John Doe\nPerson's age: 30\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-pythons-next-function\">What is Python&#8217;s next() Function?<\/h2>\n\n\n\n<p>The Python <strong>next() <\/strong>function will get the next item from the collection. So, it has two arguments such as iterator and the default value . Thus, it will return the element.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using next() function\nnumbers = iter(&#91;1, 2, 3, 4, 5])\n\n# Using next() to get the next item from the iterator\nnext_number = next(numbers)\n\n# Displaying the result\nprint(\"Next number:\", next_number)\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Next number: 1\n\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-the-python-input-function\">What is the Python input() Function?<\/h2>\n\n\n\n<p>The Python<strong> input()<\/strong> function will get the input from the user. Hence, it will ask for the user&#8217;s input and then read the line. Hence, after reading the data, it will turn the string and will return it. It will detect <strong>EOFError <\/strong>when the EOF is read.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using input() function\nuser_name = input(\"Enter your name: \")\n\n# Displaying the user input\nprint(\"Hello, \" + user_name + \"! Welcome!\")\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Enter your name: John\nHello, John! Welcome!\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-python-int-function\">What is Python int() Function?<\/h2>\n\n\n\n<p>Python <strong>int()<\/strong> function will receive an integer value. Thus, it will return with the expression which will be turned into the integer number. So, if the argument has a floating point and will be turned the number into the long type.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using int() function\nnumeric_string = \"42\"\n\n# Using int() to convert the string to an integer\nnumeric_value = int(numeric_string)\n\n# Displaying the result\nprint(\"Original string:\", numeric_string)\nprint(\"Converted integer:\", numeric_value)\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Original string: 42\nConverted integer: 42\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-a-python-isinstance-function\">What is a Python isinstance () Function?<\/h2>\n\n\n\n<p>The Python <strong>isinstance()<\/strong> function will monitor if the object is an instance of the class. But, if the object is from the class and thus it will come true. Or else, it will come false. Additionally, it will return true when the class is a subclass.<\/p>\n\n\n\n<p>Whereas,  the isinstance will have two arguments such as object and class info.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using isinstance() function\nvalue = 42\n\n# Checking if the value is an instance of the int class\nis_int_instance = isinstance(value, int)\n\n# Displaying the result\nprint(\"Value:\", value)\nprint(\"Is an instance of int:\", is_int_instance)\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Value: 42\nIs an instance of int: True\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-python-oct-function\">What is Python oct() Function?<\/h2>\n\n\n\n<p>The Python <strong>oct()  <\/strong>function will help to convert the octal value of the integer number. So, this method will take an argument and then return with the integer.  It will be turned into the octal string.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using oct() function\ndecimal_number = 42\n\n# Using oct() to convert the decimal number to octal\noctal_representation = oct(decimal_number)\n\n# Displaying the result\nprint(\"Decimal number:\", decimal_number)\nprint(\"Octal representation:\", octal_representation)\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Decimal number: 42\nOctal representation: 0o52\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-the-python-ord-function\">What is the Python ord() Function?<\/h2>\n\n\n\n<p>The <strong>ord()<\/strong> function in Python helps to return the integer which will stand for the Unicode character.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using ord() function\ncharacter = 'A'\n\n# Using ord() to get the Unicode code point of the character\nunicode_code_point = ord(character)\n\n# Displaying the result\nprint(\"Character:\", character)\nprint(\"Unicode code point:\", unicode_code_point)\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Character: A\nUnicode code point: 65<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-the-python-pow-function\">What is the Python Pow () Function?<\/h2>\n\n\n\n<p>The<strong> pow<code>()<\/code> <\/strong>function in Python helps us find the result when a number is raised to a power.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using pow() function\nbase = 2\nexponent = 3\n\n# Using pow() to find the result of 2 raised to the power of 3\nresult = pow(base, exponent)\n\n# Displaying the result\nprint(f\"{base} to the power of {exponent} is: {result}\")\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n2 to the power of 3 is: 8\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-the-python-print-function\">What is the Python  Print () Function?<\/h2>\n\n\n\n<p>The Python<strong> print() <\/strong>will help to print the given object to the screen.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using print() function\nname = \"John\"\nage = 25\n\n# Using print() to display information\nprint(\"Name:\", name)\nprint(\"Age:\", age)\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Name: John\nAge: 25\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-the-python-range-function\">What is the Python range () Function?<\/h2>\n\n\n\n<p>The Python<strong> range()<\/strong> function will help to return the immutable sequence of the numbers which begin from 0 by default, that will added by 1 and terminated at the specified number.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using range() function\n# Generate a sequence of numbers from 0 to 4 (excluding 5)\nnumbers_sequence = range(5)\n\n# Displaying the result\nprint(\"Generated sequence:\", list(numbers_sequence))\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Generated sequence: &#91;0, 1, 2, 3, 4]\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-the-python-reversed-function\">What is the Python reversed() Function?<\/h2>\n\n\n\n<p>The <strong>reversed() <\/strong>function will help to return the reversed iterator of the given sequence.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using reversed() directly in a loop\nfor num in reversed(&#91;1, 2, 3, 4, 5]):\n    print(num, end=' ')\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>5 4 3 2 1\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-a-python-round-function\">What is a Python round Function?<\/h2>\n\n\n\n<p>The Python<strong> round()<\/strong> function will allow us to round off the digits of the number and will return the floating point number.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using round() function\noriginal_number = 3.14159\n\n# Using round() to round the number to 2 decimal places\nrounded_number = round(original_number, 2)\n\n# Displaying the result\nprint(\"Original number:\", original_number)\nprint(\"Rounded number:\", rounded_number)\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Original number: 3.14159\nRounded number: 3.14\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-python-issubclass-function\">What is Python issubclass () Function?<\/h2>\n\n\n\n<p>The Python<strong> issubclass () <\/strong>function will allow us to return true if the<a href=\"https:\/\/www.skillvertex.com\/blog\/keyword-only-argument-in-python\/\" data-type=\"post\" data-id=\"7290\"> object argument<\/a> is referred to as the subclass of the second class.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example with multiple inheritance\nclass Mammal:\n    pass\n\nclass Canine(Animal, Mammal):\n    pass\n\n# Checking if Canine is a subclass of both Animal and Mammal\nis_canine_subclass = issubclass(Canine, (Animal, Mammal))\n\n# Displaying the result\nprint(\"Is Canine a subclass of Animal and Mammal?\", is_canine_subclass)\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Is Canine a subclass of Animal and Mammal? True\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-python-str\">What is Python str?<\/h2>\n\n\n\n<p>The Python <strong>str ()<\/strong> function will enable us to turn the specified value into the string.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example with a list\nmy_list = &#91;1, 2, 3]\n\n# Using str() to convert the list to a string\nlist_representation = str(my_list)\n\n# Displaying the result\nprint(\"Original list:\", my_list)\nprint(\"String representation of the list:\", list_representation)\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Original list: &#91;1, 2, 3]\nString representation of the list: &#91;1, 2, 3]\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-the-python-tuple-function\">What is the Python tuple() Function?<\/h2>\n\n\n\n<p>The Python<strong> tuple()<\/strong> function will allow us to make the tuple object.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example of creating and using a tuple\nmy_tuple = (1, 'apple', 3.14, True)\n\n# Displaying the tuple\nprint(\"Tuple:\", my_tuple)\n\n# Accessing elements in a tuple\nprint(\"First element:\", my_tuple&#91;0])\nprint(\"Second element:\", my_tuple&#91;1])\n\n# Slicing a tuple\nsubset_tuple = my_tuple&#91;1:3]\nprint(\"Subset of the tuple:\", subset_tuple)\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Tuple: (1, 'apple', 3.14, True)\nFirst element: 1\nSecond element: apple\nSubset of the tuple: ('apple', 3.14)\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-python-type-function\">What is Python type() Function?<\/h2>\n\n\n\n<p>The Python <strong>type ()<\/strong>  function will allow us to return the type of the specified object when the single argument is passed to the type () built-in function.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using type() function\nvalue1 = 42\nvalue2 = 'Hello, World!'\nvalue3 = &#91;1, 2, 3]\nvalue4 = {'a': 1, 'b': 2}\n\n# Using type() to get the type of each object\ntype_of_value1 = type(value1)\ntype_of_value2 = type(value2)\ntype_of_value3 = type(value3)\ntype_of_value4 = type(value4)\n\n# Displaying the result\nprint(\"Type of value1:\", type_of_value1)\nprint(\"Type of value2:\", type_of_value2)\nprint(\"Type of value3:\", type_of_value3)\nprint(\"Type of value4:\", type_of_value4)\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Type of value1: &lt;class 'int'&gt;\nType of value2: &lt;class 'str'&gt;\nType of value3: &lt;class 'list'&gt;\nType of value4: &lt;class 'dict'&gt;\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-the-python-vars-function\">What is the  Python vars() Function?<\/h2>\n\n\n\n<p>The Python<strong> vars() <\/strong> function will allow us to return the __dict__ attribute of the particular object.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using vars() function\nclass Person:\n    def __init__(self, name, age):\n        self.name = name\n        self.age = age\n\n# Creating an instance of the Person class\nperson_object = Person(name=\"John\", age=25)\n\n# Using vars() to get the attributes and their values\nattributes_dict = vars(person_object)\n\n# Displaying the result\nprint(\"Attributes and values:\", attributes_dict)\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Attributes and values: {'name': 'John', 'age': 25}\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-the-python-zip-function\">What is the Python zip() Function?<\/h2>\n\n\n\n<p>The Python <strong>zip() <\/strong>function will help to return the zip object and thus will analyze the similar index of the multiple containers, Hence, it will take the iterable that can create an iterator depending on the iterable passed.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Example using zip() function\nnames = &#91;'Alice', 'Bob', 'Charlie']\nages = &#91;25, 30, 22]\n\n# Using zip() to combine two lists\nzipped_data = zip(names, ages)\n\n# Converting the result to a list for better visualization\nresult_list = list(zipped_data)\n\n# Displaying the result\nprint(\"Original lists:\")\nprint(\"Names:\", names)\nprint(\"Ages:\", ages)\nprint(\"\\nZipped result:\")\nprint(result_list)\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Original lists:\nNames: &#91;'Alice', 'Bob', 'Charlie']\nAges: &#91;25, 30, 22]\n\nZipped result:\n&#91;('Alice', 25), ('Bob', 30), ('Charlie', 22)]\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\">Conclusion<\/h2>\n\n\n\n<p>Python&#8217;s built-in functions are fundamental tools that simplify coding tasks and are crucial for any programmer. This article will improve your skills and knowledge of the built-in functions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"python-built-in-functions-faq\">Python Built-in Functions -FAQ<\/h2>\n\n\n<div id=\"rank-math-faq\" class=\"rank-math-block\">\n<div class=\"rank-math-list \">\n<div id=\"faq-question-1709189329717\" class=\"rank-math-list-item\">\n<h4 class=\"rank-math-question \">Q1. What are the most used Python inbuilt functions?<\/h4>\n<div class=\"rank-math-answer \">\n\n<p>Ans. The Python inbuilt function  include\u00a0print(), abs(), round(), min(), max(), sorted(), sum(), and len().<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1709189337022\" class=\"rank-math-list-item\">\n<h4 class=\"rank-math-question \">Q2.How many structures are there in Python?<\/h4>\n<div class=\"rank-math-answer \">\n\n<p>Ans. The basic Python data structures in Python are list, set, tuples, and dictionary.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1709189345861\" class=\"rank-math-list-item\">\n<h4 class=\"rank-math-question \">Q3.What are the 4 types of functions in Python?<\/h4>\n<div class=\"rank-math-answer \">\n\n<p>Ans.\u00a0Those 4  types of functions are built-in Functions, User-defined Functions, Recursive Functions, and Lambda Functions.<\/p>\n\n<\/div>\n<\/div>\n<\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>The Python built-in -functions are referred to as the functions where the functionality is pre-defined in Python. Whereas, the Python interpreter consists of several functions that will be available for use. So, these functions are known as Python Built-in Functions. Let us check out this article to learn more about Python Built-in Functions. What is &#8230; <a title=\"Python Built-in Functions\" class=\"read-more\" href=\"https:\/\/www.skillvertex.com\/blog\/python-built-in-functions\/\" aria-label=\"More on Python Built-in Functions\">Read more<\/a><\/p>\n","protected":false},"author":4,"featured_media":7470,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[864],"tags":[953,954,57,951],"class_list":["post-7464","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python-tutorial","tag-functions","tag-programming-language","tag-python","tag-python-built-in-functions","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-33"],"_links":{"self":[{"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/posts\/7464","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/comments?post=7464"}],"version-history":[{"count":10,"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/posts\/7464\/revisions"}],"predecessor-version":[{"id":8281,"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/posts\/7464\/revisions\/8281"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/media\/7470"}],"wp:attachment":[{"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/media?parent=7464"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/categories?post=7464"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/tags?post=7464"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}