+ 2
How do I convert a number to 2 decimal place in Python
1 Antwort
+ 1
You can just simply using the round() function..
However, it rounds up to the n number, where n is a specific interger(meaning that it checks whether the number next to it is greater than 5.. if yes, it then increase n by one then remove all number after it, if not then it keeps the n and remove all number that comes after it.)
For example:
Var = 3.56789
print(round(Var,2)) #outputs 3.57 instead of 3.56