+ 1

How round numbers in Python?

I want to finish the code, but I need to know this topic. May anyone explain me "round numbers"?

27th Jan 2023, 3:35 PM
Чёртов Бог
3 ответов
+ 10
Чёртов Бог , rounding can be done in various ways with different results. so it would be a good idea to share the exercise number, or a copy of the task description. using: round(<number>,<number of digits>) => is is a *built-in* function and not part of the math module https://docs.python.org/3/library/functions.html#round floor(<number>) is a part of the math module and has to be imported https://docs.python.org/3/library/math.html#floor ceil(<number>) is a part of the math module and has to be imported https://docs.python.org/3/library/math.html#ceil
27th Jan 2023, 7:42 PM
Lothar
Lothar - avatar
+ 4
Generally, rounding a real number means making the number to nearest whole number. 1.7 to 2 1.3 to 1 Precision value greater than 0.5 then round up . Else round down or floor the value. 1.7 => 0.7 > 0.5 so nearest whole number is 2 1.3 => 0.3 < 0.5 so nearest whole number is 1. round() function is defined in math module so you can use it like : print( round(1.7) , round(1.3) ) #check its value by printing...
27th Jan 2023, 3:49 PM
Jayakrishna 🇮🇳
+ 1
Thank you very mach. Now I can finish code practice "Koleidoscopes" with this information)
27th Jan 2023, 8:09 PM
Чёртов Бог