{"id":3836,"date":"2020-08-08T11:20:15","date_gmt":"2020-08-08T05:50:15","guid":{"rendered":"http:\/\/www.pythonpool.com\/?p=3836"},"modified":"2021-09-07T10:45:33","modified_gmt":"2021-09-07T05:15:33","slug":"python-infinity","status":"publish","type":"post","link":"https:\/\/www.pythonpool.com\/python-infinity\/","title":{"rendered":"Python Infinity: Representation and Usage"},"content":{"rendered":"\n<p>Can you think of a value that can neither be defined nor estimated but is so crucial to the programming world? Yes, you got it right! Its <em>infinity<\/em>. But do you know that until 2020 there was no proper way to represent infinity in python? We generally used a <strong>larger\/small value or a garbage value<\/strong> to represent infinity.<\/p>\n\n\n\n<p><strong>Python Infinity is a variable type that is greater than every other numeric value in python. Rather than using any garbage large value as a limit, you can use pre-defined keyword for initializing an infinite value in Python.<\/strong><\/p>\n\n\n\n<p>But now we have many different ways to represent infinity. In this article, we will understand why it is essential in Computer Science and how to express it<strong> in python.<\/strong><\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_74 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #990303;color:#990303\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #990303;color:#990303\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.pythonpool.com\/python-infinity\/#How_to_Represent_Infinity_in_Python\" >How to Represent Infinity in Python?<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.pythonpool.com\/python-infinity\/#a_Using_float\" >a. Using float()<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.pythonpool.com\/python-infinity\/#b_Using_the_math_module_to_represent_infinity_in_python\" >b. Using the math module to represent infinity in python<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.pythonpool.com\/python-infinity\/#c_Using_the_Decimal_module\" >c. Using the Decimal module<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.pythonpool.com\/python-infinity\/#d_Using_the_sympy_module\" >d. Using the sympy module<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.pythonpool.com\/python-infinity\/#e_Using_the_Numpy_Module\" >e. Using the Numpy Module<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.pythonpool.com\/python-infinity\/#Performing_Operations_on_Infinity_in_python\" >Performing Operations on Infinity in python<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.pythonpool.com\/python-infinity\/#a_Adding_and_Subtracting_a_number\" >a. Adding and Subtracting a number.<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.pythonpool.com\/python-infinity\/#b_Multiply_and_Divide_some_number_with_Infinity\" >b. Multiply and Divide some number with Infinity<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.pythonpool.com\/python-infinity\/#c_Finding_Remainder_of_a_infinity_when_divides_with_a_number\" >c. Finding Remainder of a infinity when divides with a number<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.pythonpool.com\/python-infinity\/#d_Checking_if_a_number_is_infinity_using_mathisinf\" >d. Checking if a number is infinity using math.isinf()<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/www.pythonpool.com\/python-infinity\/#e_Are_all_infinity_same\" >e. Are all infinity same?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/www.pythonpool.com\/python-infinity\/#f_Comparing_the_Values_of_python_infinity_with_other_values_using_python_max_function\" >f. Comparing the Values of python infinity with other values using python max function<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/www.pythonpool.com\/python-infinity\/#g_Changing_the_type_of_python_infinity_into_integer\" >g. Changing the type of python infinity into integer<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/www.pythonpool.com\/python-infinity\/#Must_Read\" >Must Read:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/www.pythonpool.com\/python-infinity\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"h-how-to-represent-infinity-in-python\"><span class=\"ez-toc-section\" id=\"How_to_Represent_Infinity_in_Python\"><\/span>How to Represent Infinity in Python?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Infinity can be <strong>positive or negative<\/strong>. The result of any operation of any with infinity like <em>sum, product, the division is always infinity<\/em>. One more important thing is that infinity is still a <strong>float value<\/strong>. There is no way to represent infinity as an integer. So, let us now know about all the methods we can represent positive and negative infinity.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-a-using-float\"><span class=\"ez-toc-section\" id=\"a_Using_float\"><\/span>a. Using float()<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Python is a <em>dynamic language<\/em>, that is why we can use float() to represent infinity.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\npositive_inf=float('inf')\nprint(&quot;positive_inf:&quot;,positive_inf)\n\n# For negative infinity, put minus in front of positive infinity\nnegative_inf=-float('inf')\nprint(&quot;negative_inf:&quot;,negative_inf)\n<\/pre><\/div>\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"282\" src=\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/image-2-1024x282.png\" alt=\"python infinity\" class=\"wp-image-3837\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/image-2-1024x282.png 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/image-2-300x83.png 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/image-2-768x211.png 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/image-2-1536x423.png 1536w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/image-2.png 1584w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted\">positive_inf: inf\nnegative_inf: -inf<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-b-using-the-math-module-to-represent-infinity-in-python\"><span class=\"ez-toc-section\" id=\"b_Using_the_math_module_to_represent_infinity_in_python\"><\/span>b. Using the math module to represent infinity in python<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>We can use the math module to represent infinity.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport math\n# We can use the inf method of the math module\npos_infinity=math.inf\nprint(pos_infinity)\n\nneg_infinity=-math.inf\nprint(neg_infinity)\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-preformatted\">inf\n-inf<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-c-using-the-decimal-module\"><span class=\"ez-toc-section\" id=\"c_Using_the_Decimal_module\"><\/span>c. Using the Decimal module<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport decimal\n# Using the Decimal function of decimal module\npositive_inf=decimal.Decimal(&quot;inf&quot;)\nnegative_inf=-decimal.Decimal(&quot;inf&quot;)\nprint(positive_inf)\nprint(negative_inf)\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-preformatted\">Infinity\n-Infinity<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-d-using-the-sympy-module\"><span class=\"ez-toc-section\" id=\"d_Using_the_sympy_module\"><\/span>d. Using the sympy module<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nfrom sympy import oo\ninfinity=oo\nminus_infinity=-oo\nprint(infinity)\nprint(minus_infinity)\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-preformatted\">oo\n-oo<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-e-using-the-numpy-module\"><span class=\"ez-toc-section\" id=\"e_Using_the_Numpy_Module\"><\/span>e. Using the Numpy Module<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>For using the numpy library, we first need to import it using &#8211; <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">pip install numpy <\/pre>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n# importing the numpy library and giving alias np\nimport numpy as np\ninfinity=np.inf\nnegative_infinity=-np.inf\nprint(infinity)\nprint(negative_infinity)\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-preformatted\">inf\n-inf<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-performing-operations-on-infinity-in-python\"><span class=\"ez-toc-section\" id=\"Performing_Operations_on_Infinity_in_python\"><\/span>Performing Operations on Infinity in python<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-a-adding-and-subtracting-a-number\"><span class=\"ez-toc-section\" id=\"a_Adding_and_Subtracting_a_number\"><\/span>a. Adding and Subtracting a number.<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport math \ninfinity = math.inf\nval=1000\nprint(infinity+val)\nprint(infinity-val)\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-preformatted\">inf\ninf<\/pre>\n\n\n\n<p>Whatever number we add or <a href=\"http:\/\/www.pythonpool.com\/numpy-subtract\/\" target=\"_blank\" rel=\"noreferrer noopener\">subtract<\/a> from infinity, we will get infinity.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-b-multiply-and-divide-some-number-with-infinity\"><span class=\"ez-toc-section\" id=\"b_Multiply_and_Divide_some_number_with_Infinity\"><\/span>b. Multiply and Divide some number with Infinity<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport math\ninfinity = math.inf\nval=1938\nprint(infinity*val)\nprint(infinity\/val)\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-preformatted\">inf\ninf<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-c-finding-remainder-of-a-infinity-when-divides-with-a-number\"><span class=\"ez-toc-section\" id=\"c_Finding_Remainder_of_a_infinity_when_divides_with_a_number\"><\/span>c. Finding Remainder of a infinity when divides with a number<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport math \ninfinity = math.inf\nval=121212\nprint(infinity%val)\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-preformatted\">nan<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-d-checking-if-a-number-is-infinity-using-math-isinf\"><span class=\"ez-toc-section\" id=\"d_Checking_if_a_number_is_infinity_using_mathisinf\"><\/span>d. Checking if a number is infinity using math.isinf()<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>We can check if a number is infinity using the <strong>isinf()<\/strong> method of <a href=\"https:\/\/en.wikipedia.org\/wiki\/Mathematics\" target=\"_blank\" rel=\"noreferrer noopener\">math<\/a> module.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport math\nfrom sympy import oo\ninfinity=oo\nprint(math.isinf(infinity))\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-preformatted\">True<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-e-are-all-infinity-same\"><span class=\"ez-toc-section\" id=\"e_Are_all_infinity_same\"><\/span>e. Are all infinity same?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Let us now check whether the values from each methods are same or not?<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport math\nfrom decimal import Decimal\nimport numpy as np\nfrom sympy import oo\n\ninfinity=oo\ninf_floats=float('inf')\ninf_math=math.inf\ninf_Decimal=Decimal(&quot;inf&quot;)\ninf_np=np.inf\n\nprint(inf_floats==inf_math)\nprint(inf_floats==inf_Decimal)\nprint(inf_floats==inf_np)\nprint(inf_floats==infinity) # infinity value from sympy is not equal to other infinity values\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-preformatted\">True\nTrue\nTrue\nFalse<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-f-comparing-the-values-of-python-infinity-with-other-values-using-python-max-function\"><span class=\"ez-toc-section\" id=\"f_Comparing_the_Values_of_python_infinity_with_other_values_using_python_max_function\"><\/span>f. Comparing the Values of python infinity with other values using python max function<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Positive Infinity is the<strong> largest number possible and negative infinity is the smallest number.<\/strong> Let us compare some values with infinity and check whether it is true or not.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport math\nprint(max(math.inf,9999))\nprint(min(-math.inf,9999))\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-preformatted\">inf \n-inf<\/pre>\n\n\n\n<p>We can also do something like this-<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport math\n\nlarge_value=9999999999\ninfinity=math.inf\nif infinity&gt;large_value:\n    print(&quot;Infinity is the largest&quot;)\nelse:\n    print(large_value,&quot;is larger&quot;)\n    \nsmall_value=-9999999999\nneg_infinity=-math.inf\nif neg_infinity&lt;large_value:\n    print(&quot;Negative Infinity is the smallest&quot;)\nelse:\n    print(large_value,&quot;is smaller&quot;)\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-preformatted\">Infinity is the largest\nNegative Infinity is the smallest<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-g-changing-the-type-of-python-infinity-into-integer\"><span class=\"ez-toc-section\" id=\"g_Changing_the_type_of_python_infinity_into_integer\"><\/span>g. Changing the type of python infinity into integer<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Let us try to change the type  from float into integer and see what happens.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport math\ninfinity=math.inf\nint_infinity=int(infinity)\nprint(int_infinity)\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-preformatted\"><strong>Error<\/strong>: cannot convert float infinity to integer<\/pre>\n\n\n\n<h2 class=\"has-vivid-red-color has-text-color wp-block-heading\" id=\"h-must-read\"><span class=\"ez-toc-section\" id=\"Must_Read\"><\/span>Must Read:<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"http:\/\/www.pythonpool.com\/python-lowercase\/\">How to Convert String to Lowercase in<\/a><\/li><li><a href=\"http:\/\/www.pythonpool.com\/square-root-in-python\/\">How to Calculate Square Root<\/a><\/li><li><a href=\"http:\/\/www.pythonpool.com\/python-user-input\/\">User Input | Input () Function | Keyboard Input<\/a><\/li><li><a href=\"http:\/\/www.pythonpool.com\/python-book\/\">Best Book to Learn Python<\/a><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The use of infinity in computer science is great. When we want to compare a number with a very large or small number, we generally use infinity. Not only this, <strong>it can be used to measure the performance of different algorithms. It is generally used when we perform computations on a very large scale.<\/strong><\/p>\n\n\n\n<p>Try to run the programs on your side and let us know if you have any queries.<\/p>\n\n\n\n<p><strong><em>Happy Coding!<\/em><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Can you think of a value that can neither be defined nor estimated but is so crucial to the programming world? Yes, you got it &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Python Infinity: Representation and Usage\" class=\"read-more button\" href=\"https:\/\/www.pythonpool.com\/python-infinity\/#more-3836\" aria-label=\"More on Python Infinity: Representation and Usage\">Read more<\/a><\/p>\n","protected":false},"author":3,"featured_media":3857,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[15],"tags":[1952,1964,1951,1962,1955,1950,1959,1960,1965,1956,1949,1963,1953,1961,1958,1954,1957,1948],"class_list":["post-3836","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-infinity-in-python","tag-infinity-python","tag-infinity-python-variable","tag-isinf-python","tag-math-isinf-in-python","tag-mininfinity-in-python","tag-negative-infinity-in-python","tag-negative-infinity-python","tag-python-float-infinity","tag-python-infinity","tag-python-infinity-float","tag-python-infinity-int","tag-python-infinity-stack-overflow","tag-python-int-infinity","tag-python-negative-infinity","tag-python-positive-infinity","tag-sympy-python-infinity","tag-what-is-the-output-of-max-infinity-in-python-3-mcq","infinite-scroll-item"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.1 (Yoast SEO v25.0) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python Infinity: Representation and Usage - Python Pool<\/title>\n<meta name=\"description\" content=\"After 2020, python has come out with new ways to represent python infinity. We can use math, numpy, decimal module, sympy module.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pythonpool.com\/python-infinity\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Infinity: Representation and Usage\" \/>\n<meta property=\"og:description\" content=\"Can you think of a value that can neither be defined nor estimated but is so crucial to the programming world? Yes, you got it right! Its infinity. But do\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pythonpool.com\/python-infinity\/\" \/>\n<meta property=\"og:site_name\" content=\"Python Pool\" \/>\n<meta property=\"article:published_time\" content=\"2020-08-08T05:50:15+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-09-07T05:15:33+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/Fibonacci-series-in-Python-4.png\" \/>\n\t<meta property=\"og:image:width\" content=\"264\" \/>\n\t<meta property=\"og:image:height\" content=\"159\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Ashwini Mandani\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@pythonpool\" \/>\n<meta name=\"twitter:site\" content=\"@pythonpool\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ashwini Mandani\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.pythonpool.com\/python-infinity\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-infinity\/\"},\"author\":{\"name\":\"Ashwini Mandani\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/8a75fb48eb1f3dc952df65a8c28ac056\"},\"headline\":\"Python Infinity: Representation and Usage\",\"datePublished\":\"2020-08-08T05:50:15+00:00\",\"dateModified\":\"2021-09-07T05:15:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-infinity\/\"},\"wordCount\":523,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-infinity\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/Fibonacci-series-in-Python-4.png\",\"keywords\":[\"infinity in python\",\"infinity python\",\"infinity python variable\",\"isinf python\",\"math.isinf in python\",\"min(infinity) in python\",\"negative infinity in python\",\"negative infinity python\",\"python float infinity\",\"python infinity\",\"python infinity float\",\"python infinity int\",\"python infinity stack overflow\",\"python int infinity\",\"python negative infinity\",\"python positive infinity\",\"sympy python infinity\",\"what is the output of max infinity in python 3 mcq\"],\"articleSection\":[\"Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.pythonpool.com\/python-infinity\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.pythonpool.com\/python-infinity\/\",\"url\":\"https:\/\/www.pythonpool.com\/python-infinity\/\",\"name\":\"Python Infinity: Representation and Usage - Python Pool\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-infinity\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-infinity\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/Fibonacci-series-in-Python-4.png\",\"datePublished\":\"2020-08-08T05:50:15+00:00\",\"dateModified\":\"2021-09-07T05:15:33+00:00\",\"description\":\"After 2020, python has come out with new ways to represent python infinity. We can use math, numpy, decimal module, sympy module.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-infinity\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.pythonpool.com\/python-infinity\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/python-infinity\/#primaryimage\",\"url\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/Fibonacci-series-in-Python-4.png\",\"contentUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/Fibonacci-series-in-Python-4.png\",\"width\":264,\"height\":159,\"caption\":\"python infinity\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.pythonpool.com\/python-infinity\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.pythonpool.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python Infinity: Representation and Usage\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.pythonpool.com\/#website\",\"url\":\"https:\/\/www.pythonpool.com\/\",\"name\":\"Python Pool\",\"description\":\"Your One-Stop Python Learning Destination\",\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.pythonpool.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.pythonpool.com\/#organization\",\"name\":\"Python Pool\",\"url\":\"https:\/\/www.pythonpool.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/\",\"url\":\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png\",\"contentUrl\":\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png\",\"width\":452,\"height\":185,\"caption\":\"Python Pool\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/pythonpool\",\"https:\/\/www.youtube.com\/c\/pythonpool\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/8a75fb48eb1f3dc952df65a8c28ac056\",\"name\":\"Ashwini Mandani\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/f765ed1940ac0ae1d30ce4cb2f1452c1e83143b07354d25a42c1cd118980e269?s=96&d=wavatar&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/f765ed1940ac0ae1d30ce4cb2f1452c1e83143b07354d25a42c1cd118980e269?s=96&d=wavatar&r=g\",\"caption\":\"Ashwini Mandani\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Python Infinity: Representation and Usage - Python Pool","description":"After 2020, python has come out with new ways to represent python infinity. We can use math, numpy, decimal module, sympy module.","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:\/\/www.pythonpool.com\/python-infinity\/","og_locale":"en_US","og_type":"article","og_title":"Python Infinity: Representation and Usage","og_description":"Can you think of a value that can neither be defined nor estimated but is so crucial to the programming world? Yes, you got it right! Its infinity. But do","og_url":"https:\/\/www.pythonpool.com\/python-infinity\/","og_site_name":"Python Pool","article_published_time":"2020-08-08T05:50:15+00:00","article_modified_time":"2021-09-07T05:15:33+00:00","og_image":[{"width":264,"height":159,"url":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/Fibonacci-series-in-Python-4.png","type":"image\/png"}],"author":"Ashwini Mandani","twitter_card":"summary_large_image","twitter_creator":"@pythonpool","twitter_site":"@pythonpool","twitter_misc":{"Written by":"Ashwini Mandani","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.pythonpool.com\/python-infinity\/#article","isPartOf":{"@id":"https:\/\/www.pythonpool.com\/python-infinity\/"},"author":{"name":"Ashwini Mandani","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/8a75fb48eb1f3dc952df65a8c28ac056"},"headline":"Python Infinity: Representation and Usage","datePublished":"2020-08-08T05:50:15+00:00","dateModified":"2021-09-07T05:15:33+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pythonpool.com\/python-infinity\/"},"wordCount":523,"commentCount":0,"publisher":{"@id":"https:\/\/www.pythonpool.com\/#organization"},"image":{"@id":"https:\/\/www.pythonpool.com\/python-infinity\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/Fibonacci-series-in-Python-4.png","keywords":["infinity in python","infinity python","infinity python variable","isinf python","math.isinf in python","min(infinity) in python","negative infinity in python","negative infinity python","python float infinity","python infinity","python infinity float","python infinity int","python infinity stack overflow","python int infinity","python negative infinity","python positive infinity","sympy python infinity","what is the output of max infinity in python 3 mcq"],"articleSection":["Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.pythonpool.com\/python-infinity\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.pythonpool.com\/python-infinity\/","url":"https:\/\/www.pythonpool.com\/python-infinity\/","name":"Python Infinity: Representation and Usage - Python Pool","isPartOf":{"@id":"https:\/\/www.pythonpool.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.pythonpool.com\/python-infinity\/#primaryimage"},"image":{"@id":"https:\/\/www.pythonpool.com\/python-infinity\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/Fibonacci-series-in-Python-4.png","datePublished":"2020-08-08T05:50:15+00:00","dateModified":"2021-09-07T05:15:33+00:00","description":"After 2020, python has come out with new ways to represent python infinity. We can use math, numpy, decimal module, sympy module.","breadcrumb":{"@id":"https:\/\/www.pythonpool.com\/python-infinity\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pythonpool.com\/python-infinity\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/python-infinity\/#primaryimage","url":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/Fibonacci-series-in-Python-4.png","contentUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/Fibonacci-series-in-Python-4.png","width":264,"height":159,"caption":"python infinity"},{"@type":"BreadcrumbList","@id":"https:\/\/www.pythonpool.com\/python-infinity\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pythonpool.com\/"},{"@type":"ListItem","position":2,"name":"Python Infinity: Representation and Usage"}]},{"@type":"WebSite","@id":"https:\/\/www.pythonpool.com\/#website","url":"https:\/\/www.pythonpool.com\/","name":"Python Pool","description":"Your One-Stop Python Learning Destination","publisher":{"@id":"https:\/\/www.pythonpool.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.pythonpool.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.pythonpool.com\/#organization","name":"Python Pool","url":"https:\/\/www.pythonpool.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/","url":"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","contentUrl":"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","width":452,"height":185,"caption":"Python Pool"},"image":{"@id":"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/pythonpool","https:\/\/www.youtube.com\/c\/pythonpool"]},{"@type":"Person","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/8a75fb48eb1f3dc952df65a8c28ac056","name":"Ashwini Mandani","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/f765ed1940ac0ae1d30ce4cb2f1452c1e83143b07354d25a42c1cd118980e269?s=96&d=wavatar&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f765ed1940ac0ae1d30ce4cb2f1452c1e83143b07354d25a42c1cd118980e269?s=96&d=wavatar&r=g","caption":"Ashwini Mandani"}}]}},"_links":{"self":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/3836","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/comments?post=3836"}],"version-history":[{"count":6,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/3836\/revisions"}],"predecessor-version":[{"id":13490,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/3836\/revisions\/13490"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media\/3857"}],"wp:attachment":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media?parent=3836"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/categories?post=3836"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/tags?post=3836"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}