print only one decimal python code example
Example 1: python format only 1 decimal place
>>> "{0:0.1f}".format(45.34531)
'45.3'
Example 2: python round up
>>> import math
>>> math.ceil(5.2)
6
>>> math.ceil(5)
5
>>> math.ceil(-0.5)
0
Example 3: python round to dp
round(float_num, num_of_decimals)
Example 4: how to print answer 2 decimal places in python 3
print("{0:.2f}".format(sum(student_marks[query_name])/3))
Example 5: python round down
>>> int(1.6)
1
>>> int(2)
2
>>> int(3.9)
3