{"id":2940,"date":"2020-02-29T12:05:44","date_gmt":"2020-02-29T06:35:44","guid":{"rendered":"http:\/\/www.pythonpool.com\/?p=2940"},"modified":"2021-06-14T15:11:34","modified_gmt":"2021-06-14T09:41:34","slug":"python-round","status":"publish","type":"post","link":"https:\/\/www.pythonpool.com\/python-round\/","title":{"rendered":"Python Round off Techniques | Python round() Function"},"content":{"rendered":"\n<p>A rounded number has&nbsp;<strong>about the same value<\/strong>&nbsp;as the number you start with, but it is&nbsp;<strong>less exact.<\/strong> The <strong>Python round<\/strong> is also similar and works in the same way as it works in Mathematics.<br>For example, 341.7 rounded to the nearest 342. That is because 341.7 is closer in value to 342 than to 341. When rounding off to the nearest dollar, $1.89 becomes $2.00, because $1.89 is closer to $2.00 than to $1.00.<\/p>\n\n\n\n<p><strong>You can round a number or more specifically a float number. There are several ways to do Python round off. One of the most common ways is using the round() method.<\/strong><br><strong>So in this post, we will cover all the three methods to Python Round a number which is the following:<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\"><li><strong>Python rounds off number using the round() function.<\/strong><\/li><li><strong>Python round by using the format().<\/strong><\/li><li><strong>Using math.floor() function<\/strong><\/li><li><strong>Using math.ceil() method <\/strong><\/li><\/ol>\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-round\/#Python_Round_Using_round_Function\" >Python Round Using round() Function<\/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-round\/#Syntax_of_round_Function\" >Syntax of round() Function<\/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-round\/#Parameters_of_round\" >Parameters of round()<\/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-round\/#The_return_type_of_round_Function\" >The return type of round() Function<\/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-round\/#Pictorial_Presentation_of_How_round_Function_Works_in_Python\" >Pictorial Presentation of How round() Function Works in Python<\/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-round\/#Examples_of_Python_round_Function\" >Examples of Python round() Function<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.pythonpool.com\/python-round\/#Example_1_Python_Example_to_Implement_round_Function_When_Second_Parameter_is_Missing\" >Example 1: Python Example to Implement round() Function When Second Parameter is Missing<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.pythonpool.com\/python-round\/#Example_2_Python_Example_to_Implement_round_Function_When_Second_Parameter_is_Present\" >Example 2: Python Example to Implement round() Function When Second Parameter is Present<\/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-round\/#Example_3_Python_Example_to_Implement_round_Function_When_Second_Parameter_is_Negative_Number\" >Example 3: Python Example to Implement round() Function When Second Parameter is Negative Number<\/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-round\/#Example_4_Python_Example_to_Round_off_a_List_of_Floating-Point_Numbers\" >Example 4: Python Example to Round off a List of Floating-Point Numbers<\/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-round\/#Example_5_Round_off_Numpy_Arrays_using_Python_numpyround\" >Example 5:  Round off Numpy Arrays using Python numpy.round()<\/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-round\/#Note\" >Note:<\/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-round\/#Error_and_Exceptions\" >Error and Exceptions<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/www.pythonpool.com\/python-round\/#Python_Round_Using_format_Method\" >Python Round Using format() Method<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/www.pythonpool.com\/python-round\/#Using_a_Single_Formatter\" >Using a Single Formatter :<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/www.pythonpool.com\/python-round\/#Number_Formatting\" >Number Formatting<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/www.pythonpool.com\/python-round\/#Example_of_Python_Format_to_Round_a_Floating_Point_Number\" >Example of Python Format to Round a Floating Point Number:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-18\" href=\"https:\/\/www.pythonpool.com\/python-round\/#Note-2\" >Note:<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-19\" href=\"https:\/\/www.pythonpool.com\/python-round\/#Python_Round_Using_mathfloor_Function\" >Python Round Using math.floor() Function<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-20\" href=\"https:\/\/www.pythonpool.com\/python-round\/#Python_Floor_Function_Example\" >Python Floor Function Example<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-21\" href=\"https:\/\/www.pythonpool.com\/python-round\/#Python_Round_Using_mathceil_Method\" >Python Round Using math.ceil() Method<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-22\" href=\"https:\/\/www.pythonpool.com\/python-round\/#Python_ceil_Function_to_Round_off_Example\" >Python ceil Function to Round off Example<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-23\" href=\"https:\/\/www.pythonpool.com\/python-round\/#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-24\" href=\"https:\/\/www.pythonpool.com\/python-round\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"has-vivid-cyan-blue-color has-text-color wp-block-heading\"><span class=\"ez-toc-section\" id=\"Python_Round_Using_round_Function\"><\/span>Python Round Using round() Function<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The round() function is a built-in function available with python. It will return you a float number that will be rounded to the decimal places which are given as input.<\/p>\n\n\n\n<p>If the decimal places to be rounded are not specified, it is considered as 0, and it will round to the nearest integer.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Syntax_of_round_Function\"><\/span>Syntax of round() Function<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The syntax for the round() function is as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>round(number, digits)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Parameters_of_round\"><\/span>Parameters of round()<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<figure class=\"wp-block-table alignwide\"><table class=\"\"><tbody><tr><th>Name<\/th><th>Description<\/th><th>Required \/<br>Optional<\/th><\/tr><tr><td>number<\/td><td>This parameter represents the number to be rounded. <\/td><td>Required<\/td><\/tr><tr><td>digits<\/td><td>It is the optional parameter that represents the number of decimals to use when rounding the number. Default is 0.<\/td><td>Optional<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"The_return_type_of_round_Function\"><\/span>The return type of round() Function<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>This <strong>round() function in Python returns a floating-point<\/strong> number after rounding off the specified number, with the specified number of decimals.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Pictorial_Presentation_of_How_round_Function_Works_in_Python\"><\/span> <strong>Pictorial Presentation<\/strong> of How round() Function Works in Python<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1448\" height=\"2048\" src=\"https:\/\/i2.wp.com\/www.pythonpool.com\/wp-content\/uploads\/2020\/02\/Purple-Typographic-Promo-Announcement-Poster-1-scaled.jpg?fit=724%2C1024&amp;ssl=1\" alt=\"Pictorial Presentation of Python round() Function\" class=\"wp-image-2956\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/02\/Purple-Typographic-Promo-Announcement-Poster-1-scaled.jpg 1448w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/02\/Purple-Typographic-Promo-Announcement-Poster-1-212x300.jpg 212w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/02\/Purple-Typographic-Promo-Announcement-Poster-1-724x1024.jpg 724w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/02\/Purple-Typographic-Promo-Announcement-Poster-1-768x1086.jpg 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/02\/Purple-Typographic-Promo-Announcement-Poster-1-1086x1536.jpg 1086w\" sizes=\"(max-width: 1448px) 100vw, 1448px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Examples_of_Python_round_Function\"><\/span>Examples of Python round() Function<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Let&#8217;s see some examples to round off floating-point numbers in Python.<br>In these different examples, we will learn the rounding off of a floating-point number with the explanation.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Example_1_Python_Example_to_Implement_round_Function_When_Second_Parameter_is_Missing\"><\/span>Example 1: Python Example to Implement round() Function When Second Parameter is Missing<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p><em>Below is the python implementation of the round() function if the second parameter is missing.<\/em> <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># for integers\nprint(round(8))\n\n# for floating point number when decimal value is greater than 5\nprint(round(21.7))\n\n# for floating point number when decimal value is less than 5\nprint(round(11.3))\n\n# for floating point number when decimal value is equal to 5\nprint(round(4.5))<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>8\n22\n11\n4<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Example_2_Python_Example_to_Implement_round_Function_When_Second_Parameter_is_Present\"><\/span>Example 2: Python Example to Implement round() Function When Second Parameter is Present<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Now, if the second parameter is present. What will be the output? Let&#8217;s see in the below examples.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># when the last digit is = 5 \nprint(round(5.945, 2)) \n\n# when the last digit is > 5 \nprint(round(5.948, 2)) \n\n# when the last digit is &lt; 5 \nprint(round(5.942, 2)) <\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>5.95\n5.95\n5.94<\/code><\/pre>\n\n\n\n<p>In the above example, we have taken three numbers 5.945, 5.948 and 5.942. And we are limiting floats to two decimal point number. The last digits of these three numbers are <strong>equal to 5<\/strong>, <strong>greater than 5<\/strong> and <strong>less than 5.<\/strong><\/p>\n\n\n\n<p>So if the last digit is equal to 5 the number will round off to 5.95. If the last digit of the number is greater than 5 the number will also be round off to 5.95. But if the last digit is less than 5 the number will round off to 5.94.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Example_3_Python_Example_to_Implement_round_Function_When_Second_Parameter_is_Negative_Number\"><\/span>Example 3: Python Example to Implement round() Function When Second Parameter is Negative Number<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p><em>ndigits<\/em>&nbsp;can be negative numbers as well. It allows you to e.g. round numbers to ten\u2019s or hundreds. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Round to ten's\n#Example: 1\nfirst = round(74, -1)\nprint(first) \n\n#Example: 2\nsecond = round(165, -1)\nprint(second)\n\n# Round to hundred's\n#Example: 1\nthird = round(448, -2)\nprint(third)\n\n#Example: 2\nfourth = round(628, -2)\nprint(fourth)<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>70\n160\n400\n600<\/code><\/pre>\n\n\n\n<p>Here in the above example if we use ndigit as -1 it will round-off to the nearest ten&#8217;s number. And if we use -2 as the ndigit it will round off to the nearest hundredth number.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Example_4_Python_Example_to_Round_off_a_List_of_Floating-Point_Numbers\"><\/span>Example 4: Python Example to Round off a List of Floating-Point Numbers<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>A&nbsp;<strong>list<\/strong>&nbsp;is a data structure in&nbsp;<strong>Python<\/strong>&nbsp;that is a mutable, or changeable, ordered sequence of elements. Each element or value that is inside of a&nbsp;<strong>list<\/strong>&nbsp;is called an item. Just as strings are defined as characters between quotes,&nbsp;<strong>lists<\/strong>&nbsp;are defined by having values between square brackets [ ].<\/p>\n\n\n\n<p>In the following example,&nbsp;a list&nbsp;of float items is created. This is followed by using&nbsp;the for loop&nbsp;to <a href=\"http:\/\/www.pythonpool.com\/python-iterate-through-list\/\" target=\"_blank\" rel=\"noreferrer noopener\">iterate<\/a> through the list items and executing the round function on each item. The rounded items are added to a new list and displayed, have a look:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>float_lst = [31.56, 84.9, 7.632, 49.9, 80.35]\n \nrounded_list = [round(x) for x in float_lst]\n \nprint(\"List before applying the round: \",float_lst)\n \nprint(\"List after round function is applied: \",rounded_list)<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>List before applying the round:  [31.56, 84.9, 7.632, 49.9, 80.35]\nList after round function is applied:  [32, 85, 8, 50, 80]<\/code><\/pre>\n\n\n\n<p>In the above example, we rounded off all the elements of the entire list <strong>float_lst<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Example_5_Round_off_Numpy_Arrays_using_Python_numpyround\"><\/span>Example 5:  Round off Numpy Arrays using Python numpy.round()<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>A&nbsp;<strong>NumPy array<\/strong>&nbsp;is a grid of values, all of the same type, and is indexed by a tuple of nonnegative integers. The number of dimensions is the rank of the&nbsp;<strong>array<\/strong>; the shape of an&nbsp;<strong>array<\/strong>&nbsp;is a tuple of integers giving the size of the&nbsp;<strong>array<\/strong>&nbsp;along each dimension.<\/p>\n\n\n\n<p>To solve this, we can make use of NumPy module and use numpy.round() or numpy.around() method, as shown in the example below.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import numpy as np\n\narr = &#91;-0.964511, 4.75598989, 11.6955323, -0.8642326, 126.548632, -15.323]\n\nprint(np.round(arr, 2))<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91; -0.96   4.76  11.7   -0.86   126.55   -15.32]<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Note\"><\/span>Note:<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>For the built-in types supporting round(), values are rounded to the closest multiple of 10 to the <a href=\"http:\/\/www.pythonpool.com\/numpy-power\/\" target=\"_blank\" rel=\"noreferrer noopener\">power<\/a> minus n-digits. If two multiples are equally close, rounding is done toward the even choice (so, for example, both round(0.5) and round(-0.5) are 0, and round(1.5) is 2). The return value is an <a href=\"https:\/\/docs.python.org\/2.0\/ref\/integers.html\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"integer (opens in a new tab)\">integer<\/a> if called with one argument, otherwise of the same type as number.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Error_and_Exceptions\"><\/span><strong>Error and Exceptions<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>TypeError: This error is raised in the case when there is anything other than numbers in the parameters.<\/p>\n\n\n\n<h2 class=\"has-vivid-cyan-blue-color has-text-color wp-block-heading\"><span class=\"ez-toc-section\" id=\"Python_Round_Using_format_Method\"><\/span>Python Round Using format() Method<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><strong>str.format()&nbsp;is one of the&nbsp;string <a href=\"http:\/\/www.pythonpool.com\/black-git\/\" target=\"_blank\" rel=\"noopener\">formatting<\/a> methods&nbsp;in Python3, which allows multiple substitutions and value formatting. This method lets us concatenate elements within a string through positional formatting.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Using_a_Single_Formatter\"><\/span>Using a Single Formatter :<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Formatters work by putting in one or more replacement fields and placeholders defined by a pair of curly braces&nbsp;<strong>{ }&nbsp;<\/strong>into a string and calling the str.format(). The value we wish to put into the placeholders and concatenate with the string passed as parameters into the format function.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><strong>Syntax :<\/strong>\u00a0<strong>{ } .format(value)<\/strong><\/p><p><strong>Parameters :<\/strong><br><strong>(value) :<\/strong>\u00a0Can be an integer, floating point numeric constant, string, characters or even variables.<\/p><p><strong>Returntype :<\/strong>\u00a0Returns a formatted string with the value passed as parameter in the placeholder position.<\/p><\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Number_Formatting\"><\/span>Number Formatting<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The following table shows various ways to format numbers using Python\u2019s str.format(), including examples for both float formatting and integer formatting.<\/p>\n\n\n\n<p>To run examples use:&nbsp;<code>print(\"FORMAT\".format(NUMBER));<\/code><\/p>\n\n\n\n<p>To get the output of the first example, formatting afloat to two decimal places, you would run:<\/p>\n\n\n\n<p><code>print(\"{:.2f}\".format(3.1415926));<\/code><\/p>\n\n\n\n<figure class=\"wp-block-table alignwide\"><table class=\"\"><tbody><tr><th>Number<\/th><th>Format<\/th><th>Output<\/th><th>Description<\/th><\/tr><tr><td>3.1415926<\/td><td>{:.2f}<\/td><td>3.14<\/td><td>Format float 2 decimal places<\/td><\/tr><tr><td>3.1415926<\/td><td>{:+.2f}<\/td><td>+3.14<\/td><td>Format float 2 decimal places with a sign<\/td><\/tr><tr><td>-1<\/td><td>{:+.2f}<\/td><td>-1.00<\/td><td>Format float 2 decimal places with a sign<\/td><\/tr><tr><td>2.71828<\/td><td>{:.0f}<\/td><td>3<\/td><td>Format float with no decimal places<\/td><\/tr><tr><td>5<\/td><td>{:0&gt;2d}<\/td><td>05<\/td><td>Pad number with zeros (left padding, width 2)<\/td><\/tr><tr><td>5<\/td><td>{:x&lt;4d}<\/td><td>5xxx<\/td><td>Pad number with x\u2019s (right padding, width 4)<\/td><\/tr><tr><td>10<\/td><td>{:x&lt;4d}<\/td><td>10xx<\/td><td>Pad number with x\u2019s (right padding, width 4)<\/td><\/tr><tr><td>1000000<\/td><td>{:,}<\/td><td>1,000,000<\/td><td>Number format with a comma separator<\/td><\/tr><tr><td>0.25<\/td><td>{:.2%}<\/td><td>25.00%<\/td><td>Format percentage<\/td><\/tr><tr><td>1000000000<\/td><td>{:.2e}<\/td><td>1.00e+09<\/td><td>Exponent notation<\/td><\/tr><tr><td>13<\/td><td>{:10d}<\/td><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;13<\/td><td>Right aligned (default, width 10)<\/td><\/tr><tr><td>13<\/td><td>{:&lt;10d}<\/td><td>13<\/td><td>Left aligned (width 10)<\/td><\/tr><tr><td>13<\/td><td>{:^10d}<\/td><td>&nbsp;&nbsp;&nbsp;&nbsp;13<\/td><td>Center aligned (width 10)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Example_of_Python_Format_to_Round_a_Floating_Point_Number\"><\/span>Example of Python Format to Round a Floating Point Number:<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># Convert base-10 decimal integers \n# to floating point numeric constants \nprint (\"This site is {0:f}% securely {1}!!\".format(100, \"encrypted\")) \n\n# To limit the precision \nprint (\"My average of this {0} was {1:.2f}%\".format(\"semester\", 78.234876)) \n\n# For no decimal places \nprint (\"My average of this {0} was {1:.0f}%\".format(\"semester\", 78.234876)) \n\n# Convert an integer to its binary or \n# with other different converted bases. \nprint(\"The {0} of 100 is {1:b}\".format(\"binary\", 100)) \n\t\t\nprint(\"The {0} of 100 is {1:o}\".format(\"octal\", 100)) <\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>This site is 100.000000% securely encrypted!!\nMy average of this semester was 78.23%\nMy <a href=\"http:\/\/www.pythonpool.com\/moving-average-python\/\" target=\"_blank\" rel=\"noopener\">average<\/a> of this semester was 78%\nThe binary of 100 is 1100100\nThe octal of 100 is 144<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Note-2\"><\/span>Note:<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>if the goal of rounding a number is to add it to a string, a solution is to use\u00a0format().<\/p>\n\n\n\n<h2 class=\"has-vivid-cyan-blue-color has-text-color wp-block-heading\"><span class=\"ez-toc-section\" id=\"Python_Round_Using_mathfloor_Function\"><\/span>Python Round Using math.floor() Function<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In Python, the math module contains a number of mathematical operations, which can be performed with ease using the module.\u00a0<code><strong>math.floor()<\/strong><\/code>\u00a0function returns the largest integer not greater than x. If the number is already an integer, the same number is returned.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>Syntax:<\/strong> math.floor(x)\n\n<strong>Parameter:<\/strong>\n<strong>x:<\/strong> This is a numeric expression.\n\n<strong>Returns:<\/strong>  largest integer not greater than x.<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Python_Floor_Function_Example\"><\/span>Python Floor Function Example<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The floor Function in Python is used to return the closest integer value which is less than or equal to given numeric value.<\/p>\n\n\n\n<p>Let me show you a simple example of floor function that returns the closet value of 12.95<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Python floor function example\n \nimport math\n \nval = math.floor(12.95)\nprint(val)<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Python floor function example\n \nimport math\n \nval = math.floor(12.95)\nprint(val)<\/code><\/pre>\n\n\n\n<h2 class=\"has-vivid-cyan-blue-color has-text-color wp-block-heading\"><span class=\"ez-toc-section\" id=\"Python_Round_Using_mathceil_Method\"><\/span>Python Round Using math.ceil() Method<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In Python, the math module contains a number of mathematical operations, which can be performed with ease using the module.\u00a0math.ceil()\u00a0the function returns the smallest integral value greater than the number. If the number is already an integer, the same number is returned.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>Syntax:<\/strong> math.ceil(x)\n\n<strong>Parameter:<\/strong>\n<strong>x:<\/strong> This is a numeric expression.\n\n<strong>Returns:<\/strong>  Smallest integer not less than x.<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Python_ceil_Function_to_Round_off_Example\"><\/span>Python ceil Function to Round off Example<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The Python ceil Function allows you to find the smallest integer value, which is greater than or equal to the numeric values.\u00a0In this example, We are going to find the ceiling values of different data types and display the output.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Python CEIL Function Example\n\nimport math\n\nTup = (10.98, 20.26, 30.05, -40.95 , 50.45) # Tuple Declaration\nLis = &#91;-10.98, 32.65, -39.59, -42.15 , 35.97] # List Declaration\n\nprint('Ceiling value of Positive Number = %.2f' %math.ceil(10))\nprint('Ceiling value of Negative Number = %.2f' %math.ceil(-15))\n\nprint('Ceiling value of Tuple Item = %.2f' %math.ceil(Tup&#91;2]))\nprint('Ceiling value of List Item = %.2f' %math.ceil(Lis&#91;2]))\n\nprint(\"The Value of 'PI' after the Ceil function is: \", math.ceil(math.pi))\n\nprint('Ceiling value of Multiple Number = %.2f' %math.ceil(10 + 20 - 40.65))\n\nprint('Ceiling value of String Number = ', math.ceil('Python'))<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Ceiling value of Positive Number = 10.00\nCeiling value of Negative Number = -15.00\nCeiling value of Tuple Item = 31.00\nCeiling value of List Item = -39.00\nThe Value of 'PI' after the Ceil function is:  4\nCeiling value of Multiple Number = -10.00\nTraceback (most recent call last):\n  File \"c:\/Users\/Karan\/Desktop\/test.py\", line 18, in &lt;module>\n    print('Ceiling value of String Number = ', math.ceil('Python'))\nTypeError: must be real number, not str<\/code><\/pre>\n\n\n\n<p>In the above example you can see there is a type error.  When we apply the ceil() function to the string.<\/p>\n\n\n\n<p>So Here point to be noted is that the ceil() Function can round-off only the numerical values in Python.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><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 in 2020<\/a><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>You can use the <strong>Python round<\/strong> function to round a number to a certain decimal place. This can be helpful if you\u2019re working with mathematical calculations that return numbers with unnecessary decimal places, or if you are working with values like <a href=\"http:\/\/www.pythonpool.com\/python-bitcoinlib\/\" target=\"_blank\" rel=\"noopener\">money<\/a> which typically do not show more than two decimal places.<\/p>\n\n\n\n<p>In this tutorial, we discussed how to use the\u00a0<code>round()<\/code>\u00a0function to round numbers in Python. We then explored other methods like format(), floor(), and ceil() to round off the numbers in python programming. Now you\u2019re ready to start rounding numbers in Python like an expert!<\/p>\n\n\n\n<p>Try to run the programs on your side and let me 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>A rounded number has&nbsp;about the same value&nbsp;as the number you start with, but it is&nbsp;less exact. The Python round is also similar and works in &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Python Round off Techniques | Python round() Function\" class=\"read-more button\" href=\"https:\/\/www.pythonpool.com\/python-round\/#more-2940\" aria-label=\"More on Python Round off Techniques | Python round() Function\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":2963,"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":[817,806,800,793,812,805,791,795,797,809,802,798,811,801,810,792,808,815,803,794,796,799,807,816,804],"class_list":["post-2940","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-how-to-round-decimals-in-python","tag-how-to-round-down-in-python","tag-how-to-round-in-python","tag-knights-of-the-round-table-monty-python","tag-monty-python-knights-of-the-round-table","tag-python-3-round-to-2-decimal-places","tag-python-round","tag-python-round-down","tag-python-round-float","tag-python-round-function","tag-python-round-to-2-decimal-places","tag-python-round-to-2-decimals","tag-python-round-to-integer","tag-python-round-to-nearest-integer","tag-python-round-to-two-decimals","tag-python-round-up","tag-round-down-python","tag-round-function-in-python","tag-round-function-python","tag-round-in-python","tag-round-number-python","tag-round-python","tag-round-to-2-decimal-places-python","tag-round-up-in-python","tag-round-up-python","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 Round off Techniques | Python round() Function - Python Pool<\/title>\n<meta name=\"description\" content=\"There are several ways to python round off a floating-point number. One of the most common ways is using the python round() method.\" \/>\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-round\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Round off Techniques | Python round() Function\" \/>\n<meta property=\"og:description\" content=\"A rounded number has&nbsp;about the same value&nbsp;as the number you start with, but it is&nbsp;less exact. The Python round is also similar and works in\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pythonpool.com\/python-round\/\" \/>\n<meta property=\"og:site_name\" content=\"Python Pool\" \/>\n<meta property=\"article:published_time\" content=\"2020-02-29T06:35:44+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-06-14T09:41:34+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/02\/Capture-28.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1017\" \/>\n\t<meta property=\"og:image:height\" content=\"613\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Python Pool\" \/>\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=\"Python Pool\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.pythonpool.com\/python-round\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-round\/\"},\"author\":{\"name\":\"Python Pool\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/f87448ee54c0ffd2889fbf2408c18998\"},\"headline\":\"Python Round off Techniques | Python round() Function\",\"datePublished\":\"2020-02-29T06:35:44+00:00\",\"dateModified\":\"2021-06-14T09:41:34+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-round\/\"},\"wordCount\":1535,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-round\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/02\/Capture-28.jpg\",\"keywords\":[\"how to round decimals in python\",\"how to round down in python\",\"how to round in python\",\"knights of the round table monty python\",\"monty python knights of the round table\",\"python 3 round to 2 decimal places\",\"python round\",\"python round down\",\"python round float\",\"python round function\",\"python round to 2 decimal places\",\"python round to 2 decimals\",\"python round to integer\",\"python round to nearest integer\",\"python round to two decimals\",\"python round up\",\"round down python\",\"round function in python\",\"round function python\",\"round in python\",\"round number python\",\"round python\",\"round to 2 decimal places python\",\"round up in python\",\"round up python\"],\"articleSection\":[\"Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.pythonpool.com\/python-round\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.pythonpool.com\/python-round\/\",\"url\":\"https:\/\/www.pythonpool.com\/python-round\/\",\"name\":\"Python Round off Techniques | Python round() Function - Python Pool\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-round\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-round\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/02\/Capture-28.jpg\",\"datePublished\":\"2020-02-29T06:35:44+00:00\",\"dateModified\":\"2021-06-14T09:41:34+00:00\",\"description\":\"There are several ways to python round off a floating-point number. One of the most common ways is using the python round() method.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-round\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.pythonpool.com\/python-round\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/python-round\/#primaryimage\",\"url\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/02\/Capture-28.jpg\",\"contentUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/02\/Capture-28.jpg\",\"width\":1017,\"height\":613,\"caption\":\"Python Round\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.pythonpool.com\/python-round\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.pythonpool.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python Round off Techniques | Python round() Function\"}]},{\"@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\/f87448ee54c0ffd2889fbf2408c18998\",\"name\":\"Python Pool\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/fdd3cb9ad7f560324dfd481989550aa8ffce84388fd253c42beca35c999d3108?s=96&d=wavatar&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/fdd3cb9ad7f560324dfd481989550aa8ffce84388fd253c42beca35c999d3108?s=96&d=wavatar&r=g\",\"caption\":\"Python Pool\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Python Round off Techniques | Python round() Function - Python Pool","description":"There are several ways to python round off a floating-point number. One of the most common ways is using the python round() method.","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-round\/","og_locale":"en_US","og_type":"article","og_title":"Python Round off Techniques | Python round() Function","og_description":"A rounded number has&nbsp;about the same value&nbsp;as the number you start with, but it is&nbsp;less exact. The Python round is also similar and works in","og_url":"https:\/\/www.pythonpool.com\/python-round\/","og_site_name":"Python Pool","article_published_time":"2020-02-29T06:35:44+00:00","article_modified_time":"2021-06-14T09:41:34+00:00","og_image":[{"width":1017,"height":613,"url":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/02\/Capture-28.jpg","type":"image\/jpeg"}],"author":"Python Pool","twitter_card":"summary_large_image","twitter_creator":"@pythonpool","twitter_site":"@pythonpool","twitter_misc":{"Written by":"Python Pool","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.pythonpool.com\/python-round\/#article","isPartOf":{"@id":"https:\/\/www.pythonpool.com\/python-round\/"},"author":{"name":"Python Pool","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/f87448ee54c0ffd2889fbf2408c18998"},"headline":"Python Round off Techniques | Python round() Function","datePublished":"2020-02-29T06:35:44+00:00","dateModified":"2021-06-14T09:41:34+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pythonpool.com\/python-round\/"},"wordCount":1535,"commentCount":0,"publisher":{"@id":"https:\/\/www.pythonpool.com\/#organization"},"image":{"@id":"https:\/\/www.pythonpool.com\/python-round\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/02\/Capture-28.jpg","keywords":["how to round decimals in python","how to round down in python","how to round in python","knights of the round table monty python","monty python knights of the round table","python 3 round to 2 decimal places","python round","python round down","python round float","python round function","python round to 2 decimal places","python round to 2 decimals","python round to integer","python round to nearest integer","python round to two decimals","python round up","round down python","round function in python","round function python","round in python","round number python","round python","round to 2 decimal places python","round up in python","round up python"],"articleSection":["Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.pythonpool.com\/python-round\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.pythonpool.com\/python-round\/","url":"https:\/\/www.pythonpool.com\/python-round\/","name":"Python Round off Techniques | Python round() Function - Python Pool","isPartOf":{"@id":"https:\/\/www.pythonpool.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.pythonpool.com\/python-round\/#primaryimage"},"image":{"@id":"https:\/\/www.pythonpool.com\/python-round\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/02\/Capture-28.jpg","datePublished":"2020-02-29T06:35:44+00:00","dateModified":"2021-06-14T09:41:34+00:00","description":"There are several ways to python round off a floating-point number. One of the most common ways is using the python round() method.","breadcrumb":{"@id":"https:\/\/www.pythonpool.com\/python-round\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pythonpool.com\/python-round\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/python-round\/#primaryimage","url":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/02\/Capture-28.jpg","contentUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/02\/Capture-28.jpg","width":1017,"height":613,"caption":"Python Round"},{"@type":"BreadcrumbList","@id":"https:\/\/www.pythonpool.com\/python-round\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pythonpool.com\/"},{"@type":"ListItem","position":2,"name":"Python Round off Techniques | Python round() Function"}]},{"@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\/f87448ee54c0ffd2889fbf2408c18998","name":"Python Pool","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/fdd3cb9ad7f560324dfd481989550aa8ffce84388fd253c42beca35c999d3108?s=96&d=wavatar&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/fdd3cb9ad7f560324dfd481989550aa8ffce84388fd253c42beca35c999d3108?s=96&d=wavatar&r=g","caption":"Python Pool"}}]}},"_links":{"self":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/2940","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\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/comments?post=2940"}],"version-history":[{"count":62,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/2940\/revisions"}],"predecessor-version":[{"id":24523,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/2940\/revisions\/24523"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media\/2963"}],"wp:attachment":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media?parent=2940"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/categories?post=2940"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/tags?post=2940"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}