How to round a float to the nearest 0.1 in Python

2 Answers

0 votes
_float = 5.789

_float = round(_float, 1)

print(_float) 



'''
run:

5.8

'''

 



answered Jul 30, 2022 by avibootz
0 votes
_float = 5.128

_float = round(_float, 1)

print(_float) 



'''
run:

5.1

'''

 



answered Jul 30, 2022 by avibootz

Related questions

1 answer 212 views
1 answer 203 views
3 answers 568 views
1 answer 274 views
...