{"id":2260,"date":"2021-02-20T10:57:24","date_gmt":"2021-02-20T10:57:24","guid":{"rendered":"https:\/\/www.pythontutorial.net\/?page_id=2260"},"modified":"2022-11-24T00:05:07","modified_gmt":"2022-11-24T00:05:07","slug":"python-rounding","status":"publish","type":"page","link":"https:\/\/www.pythontutorial.net\/advanced-python\/python-rounding\/","title":{"rendered":"Python Rounding"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you&#8217;ll learn how to use the Python <code>round()<\/code> function to round a number.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='introduction-to-the-python-round-function'>Introduction to the Python round() function <a href=\"#introduction-to-the-python-round-function\" class=\"anchor\" id=\"introduction-to-the-python-round-function\" title=\"Anchor for Introduction to the Python &lt;code&gt;round()&lt;\/code&gt; function\">#<\/a><\/h2>\n\n\n\n<p>Rounding means making a number simpler but keeping its value close to its original value. For example, 89 rounded to the nearest ten is 90 because 89 is closer to 90 than to 80.<\/p>\n\n\n\n<p>To round a number in Python, you use the built-in <code>round()<\/code> function:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">round(number &#91;, ndigits])<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The <code>round()<\/code> function rounds the <code>number<\/code> to the closest multiple of 10<sup>-ndigits<\/sup>.<\/p>\n\n\n\n<p>In other words, the <code>round()<\/code> function returns the <code>number<\/code> rounded to <code>ndigits<\/code> precision after the decimal point.<\/p>\n\n\n\n<p>If  <code>ndigits<\/code> is omitted or <code>None<\/code>, the <code>round()<\/code> will return the nearest integer.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='python-round-function-examples'>Python round() function examples <a href=\"#python-round-function-examples\" class=\"anchor\" id=\"python-round-function-examples\" title=\"Anchor for Python round() function examples\">#<\/a><\/h2>\n\n\n\n<p>Let&#8217;s take some examples to understand the <code>round()<\/code> function better.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id='1-python-round-function-examples'>1) Python round() function examples <a href=\"#1-python-round-function-examples\" class=\"anchor\" id=\"1-python-round-function-examples\" title=\"Anchor for 1) Python &lt;code&gt;round()&lt;\/code&gt; function examples\">#<\/a><\/h3>\n\n\n\n<p>The following example uses the <code>round()<\/code> function without passing the <code>ndigits<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">round(<span class=\"hljs-number\">1.25<\/span>)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-number\">1<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>It returns an integer <code>1<\/code>.<\/p>\n\n\n\n<p>However, if you pass <code>ndigits<\/code> as zero, the <code>round()<\/code> function returns a <a href=\"https:\/\/www.pythontutorial.net\/advanced-python\/python-float\/\">float<\/a> 1.0:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">round(<span class=\"hljs-number\">1.25<\/span>, <span class=\"hljs-number\">0<\/span>)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-number\">1.0<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The following illustrates how the <code>round()<\/code> function works under the hood:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"297\" height=\"193\" src=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2021\/02\/Python-rounding-round-example.png\" alt=\"\" class=\"wp-image-2267\"\/><\/figure>\n<\/div>\n\n\n<p>Since <code>ndigits<\/code> is zero, the <code>round()<\/code> function rounds the number <code>1.25<\/code> to the closet multiple of 10<sup>-(0)<\/sup> = 1.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id='2-python-round-function-example-with-negative-ndigits'>2) Python round() function example with negative ndigits <a href=\"#2-python-round-function-example-with-negative-ndigits\" class=\"anchor\" id=\"2-python-round-function-example-with-negative-ndigits\" title=\"Anchor for 2) Python round() function example with negative ndigits\">#<\/a><\/h3>\n\n\n\n<p>The following example uses the <code>round()<\/code> function with negative <code>ndigits<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">round(<span class=\"hljs-number\">15.5<\/span>, <span class=\"hljs-number\">-1<\/span>)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Because <code>ndigits<\/code> is <code>-1<\/code>, the <code>round()<\/code> function rounds the number <code>15.5<\/code> to the closest multiple of <code>20<\/code> (10<sup>-(-1)<\/sup>):<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"297\" height=\"186\" src=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2021\/02\/Python-rounding-round-to-the-nearest-ten.png\" alt=\"\" class=\"wp-image-2269\"\/><\/figure>\n<\/div>\n\n\n<p>Since <code>15.5<\/code> is situated between <code>10<\/code> and <code>20<\/code> (multiple of <code>10<\/code>), it&#8217;s closer to <code>20<\/code>. Therefore, the <code>round()<\/code> function returns <code>20<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id='3-python-round-function-example-with-ties'>3) Python round() function example with ties <a href=\"#3-python-round-function-example-with-ties\" class=\"anchor\" id=\"3-python-round-function-example-with-ties\" title=\"Anchor for 3) Python &lt;code&gt;round()&lt;\/code&gt; function example with ties\">#<\/a><\/h3>\n\n\n\n<p>When you round a number situated in the middle of two numbers, Python cannot find the closest number.<\/p>\n\n\n\n<p>For example, if you round the number <code>1.25<\/code> with n is <code>1<\/code>. There will be no closest number:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"297\" height=\"176\" src=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2021\/02\/Python-rounding-round-to-the-nearest-ten-with-tie.png\" alt=\"\" class=\"wp-image-2270\"\/><\/figure>\n<\/div>\n\n\n<p>In this case, Python uses the IEEE 754 standard for rounding, called the banker&#8217;s rounding.<\/p>\n\n\n\n<p>In the banker&#8217;s rounding, a number is rounded to the nearest value, with ties rounded to the nearest value with an <strong>even least significant digit<\/strong>.<\/p>\n\n\n\n<p class=\"note\">Generally, the least significant digit in a number is the rightmost digit.<\/p>\n\n\n\n<p>The banker&#8217;s rounding comes from the idea that statistically 50% sample of numbers are rounded up and 50% are rounded down.<\/p>\n\n\n\n<p>For example:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">round(<span class=\"hljs-number\">1.25<\/span>, <span class=\"hljs-number\">1<\/span>)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>It returns 1.2<\/p>\n\n\n\n<p>Because the least significant digit of <code>1.2<\/code> is <code>2<\/code>, which is even:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"294\" height=\"183\" src=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2021\/02\/Python-rounding-banker-rounding-example-2.png\" alt=\"\" class=\"wp-image-2273\"\/><\/figure>\n<\/div>\n\n\n<p>Similarly, the rounding of <code>1.35<\/code> will return <code>1.4<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">round(<span class=\"hljs-number\">1.35<\/span>, <span class=\"hljs-number\">1<\/span>)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"297\" height=\"211\" src=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2021\/02\/Python-rounding-banker-rounding-example-2-1.png\" alt=\"\" class=\"wp-image-2274\"\/><\/figure>\n<\/div>\n\n\n<p>Python uses banker&#8217;s rounding but not rounding away from zero because it&#8217;s less biased.<\/p>\n\n\n\n<p>For example, if you average three numbers <code>1.5<\/code>, <code>2.5<\/code>, and <code>3.5<\/code>, the rounding away from zero returns <code>3<\/code>.0 while the banker&#8217;s rounding returns <code>2.66<\/code>:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Number<\/th><th>Banker&#8217;s Rounding<\/th><th>Rounding away from zero<\/th><\/tr><\/thead><tbody><tr><td>1.5<\/td><td>2<\/td><td>2<\/td><\/tr><tr><td>2.5<\/td><td>2<\/td><td>3<\/td><\/tr><tr><td>3.5<\/td><td>4<\/td><td>4<\/td><\/tr><\/tbody><tfoot><tr><td><strong>Average<\/strong><\/td><td>2.66666&#8230;<\/td><td>3.0<\/td><\/tr><\/tfoot><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id='how-to-round-away-from-zero'>How to round away from zero <a href=\"#how-to-round-away-from-zero\" class=\"anchor\" id=\"how-to-round-away-from-zero\" title=\"Anchor for How to round away from zero\">#<\/a><\/h2>\n\n\n\n<p>Python doesn&#8217;t provide a direct way to round a number away from zero as you might expect. For example:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Number<\/th><th>Rounding away from zero<\/th><\/tr><\/thead><tbody><tr><td>1.2<\/td><td>1<\/td><\/tr><tr><td>1.5<\/td><td>2<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>A common way to round a number away from zero is to use the following expression:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">int(x + <span class=\"hljs-number\">0.5<\/span>)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>This expression works correctly for positive numbers. For example:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">print(int(<span class=\"hljs-number\">1.2<\/span> + <span class=\"hljs-number\">0.5<\/span>))\nprint(int(<span class=\"hljs-number\">1.5<\/span> + <span class=\"hljs-number\">0.5<\/span>))<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-number\">1<\/span>\n<span class=\"hljs-number\">2<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>However, it doesn&#8217;t work for the negative numbers:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-12\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">print(int(<span class=\"hljs-number\">-1.2<\/span> + <span class=\"hljs-number\">0.5<\/span>))\nprint(int(<span class=\"hljs-number\">-1.5<\/span> + <span class=\"hljs-number\">0.5<\/span>))<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-12\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-13\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-number\">0<\/span>\n<span class=\"hljs-number\">-1<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-13\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>For negative numbers, you should subtract 0.5 instead of adding it.<\/p>\n\n\n\n<p>The following example works properly for the negative numbers:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-14\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">print(int(<span class=\"hljs-number\">-1.2<\/span> - <span class=\"hljs-number\">0.5<\/span>))\nprint(int(<span class=\"hljs-number\">-1.5<\/span> - <span class=\"hljs-number\">0.5<\/span>))<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-14\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The following defines a helper function that rounds up a number:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-15\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-function\"><span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title\">round_up<\/span><span class=\"hljs-params\">(x)<\/span>:<\/span>\n    <span class=\"hljs-keyword\">if<\/span> x &gt; <span class=\"hljs-number\">0<\/span>:\n        <span class=\"hljs-keyword\">return<\/span> int(x + <span class=\"hljs-number\">0.5<\/span>)\n    <span class=\"hljs-keyword\">return<\/span> int(x - <span class=\"hljs-number\">0.5<\/span>)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-15\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The Python <code>math<\/code> module provides you with a function called <code>copysign()<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-16\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">math.copysign(x, y)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-16\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The <code>copysign()<\/code> function returns the absolute value of <code>x<\/code> but the sign of <code>y<\/code>.<\/p>\n\n\n\n<p>And you can use this <code>copysign()<\/code> function to develop a <code>round_up()<\/code> function without checking whether <code>x<\/code> is positive or negative:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-17\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-keyword\">from<\/span> math <span class=\"hljs-keyword\">import<\/span> copysign\n\n<span class=\"hljs-function\"><span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title\">round_up<\/span><span class=\"hljs-params\">(x)<\/span>:<\/span>\n    <span class=\"hljs-keyword\">return<\/span> int(x + copysign(<span class=\"hljs-number\">0.5<\/span>, x))<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-17\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id='summary'>Summary <a href=\"#summary\" class=\"anchor\" id=\"summary\" title=\"Anchor for Summary\">#<\/a><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use the <code>round(number, ndigits)<\/code> function to round a <code>number<\/code> to the <code>ndigits<\/code> precision after the decimal point.<\/li>\n<\/ul>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful ?<\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"2260\"\n\t\t\t\tdata-post-url=\"https:\/\/www.pythontutorial.net\/advanced-python\/python-rounding\/\"\n\t\t\t\tdata-post-title=\"Python Rounding\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"2260\"\n\t\t\t\tdata-post-url=\"https:\/\/www.pythontutorial.net\/advanced-python\/python-rounding\/\"\n\t\t\t\tdata-post-title=\"Python Rounding\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\t\t\t<input type=\"button\" name=\"wth-submit\" class=\"wth-btn wth-btn-submit\" id=\"wth-submit\" \/>\n\t\t\t<input type=\"button\" class=\"wth-btn wth-btn-cancel\" value=\"Cancel\" \/>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Summary: in this tutorial, you&#8217;ll learn how to use the Python round() function to round a number. Introduction to the Python round() function # Rounding means making a number simpler but keeping its value close to its original value. For example, 89 rounded to the nearest ten is 90 because 89 is closer to 90 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":757,"menu_order":32,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-2260","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/pages\/2260","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/comments?post=2260"}],"version-history":[{"count":0,"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/pages\/2260\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/pages\/757"}],"wp:attachment":[{"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/media?parent=2260"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}