>>> x = 13.949999999999999999
>>> x
13.95
>>> g = float("{0:.2f}".format(x))
>>> g
13.95
>>> x == g
True
>>> h = round(x, 2)
>>> h
13.95
>>> x == h
True
>>> round(1.4756,2)
1.48
>>> round(1.3333,2)
1.33
answer = str(round(answer, 2))
format(1.4000,'.2f') #to include zeroes while rounding to 2 decimals
answer = round(answer, 2)
f"{num:.1f}"
round(1.4756, 2)
# 1.48
round(1.3333, 2)
# 1.33
round(number, decimal places)
floatNumber = 2.13400
#Method 1: use f-strings
print(f"{floatNumber:.5f}") #Output: 2.13400 == '%.5f'%floatNumber
#Method 2: use round
print(round(floatNumber,5)) #Output: 2.134
value = 5.34343
rounded_value = round(value, 2) # 5.34
import math
val = 3.14
math.floor(val) # rounds down --> 3
math.ceil(val) # rounds up val --> 4