so i had this problem where i generated numbers from 0-1 with a step of 0.01 but the numbers have so many decimals like 0.010101010101.I only need it in the form 0.01 with two decimals.
How do i remove the rest of decimals ?
so i had this problem where i generated numbers from 0-1 with a step of 0.01 but the numbers have so many decimals like 0.010101010101.I only need it in the form 0.01 with two decimals.
How do i remove the rest of decimals ?
You can format the decimal like
your_value = 0.1010101010
desired_value = '%.2f' % your_value
Now desired_value
will have the decimal upto 2 places.
Or you could use decimal. Look at the documentation in the link: https://docs.python.org/3/library/decimal.html