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 117 views
1 answer 96 views
3 answers 399 views
1 answer 164 views
...