Renan Moura

Renan Moura

I'm a Software Engineer working in the industry for a decade now. I like to solve problems with as little code as possible. I’m interested in solving all sorts of problems with technology in creative and innovative ways. From everyday shell scripts to machine learning models. I write about Software Development, Machine Learning, and Career in tech.

How to round a number in Python

round()

The round() function rounds a given number with the specified number of decimals. If you don’t specify the number of decimals, the default will be zero decimals. print(round(32.8476)) print(round(32.8476,1)) print(round(32.8476,2)) print(round(32.8476,3)) 33 32.8 32.85 32.848