0

So, I want to round the output to the nearest 10,000th (the output will be printed in decimals). However, when I used round(), nothing happened. What should I change in my code so that it prints the right output?

Edit So this is my output from the code

2.4586597040905134

and what I want the output to look like is the same thing but rounded to the 10,000th place so, I want the output should look like this,

2.45866

Like when I used round(), the same 2.4586597040905134 came up. Are there any issues with syntax for assertion for this?

Bruffff
  • 53
  • 7
  • why dont you use the [previous answer](https://stackoverflow.com/questions/69855361/how-can-i-implement-a-function-to-print-out-for-all-similar-strings/69855764#69855764) – balderman Nov 06 '21 at 10:48
  • that answer is great but I'm not allowed to import stuff for this 'assignment'. So I wrote up this code and now encountered this issue (the question) – Bruffff Nov 06 '21 at 10:50
  • @balderman thank u for taking ur time off to answer that one though. I hv upvoted it. – Bruffff Nov 06 '21 at 10:52
  • The `import` are coming from core python libraries. You should add this constraint to the post. – balderman Nov 06 '21 at 10:55
  • Add an example of what **exactly** you need. If the problem is to convert a number - share the original value and the desired value. – balderman Nov 06 '21 at 10:56
  • @Bruffff That is exactly what `round(value, 5)` does. Why doesn't round work for you? E.g. show what you tried with `round`. – MegaIng Nov 06 '21 at 11:03
  • Aha sorry I see. You pass to round the number of digits, not which number length you want (e.g. `5`, not `100000000`) – MegaIng Nov 06 '21 at 11:04
  • @Megaing ohhhh, yea I got it now, thank u very much – Bruffff Nov 06 '21 at 11:06
  • Does this answer your question? [How to round to 2 decimals with Python?](https://stackoverflow.com/questions/20457038/how-to-round-to-2-decimals-with-python) – SuperStormer Nov 07 '21 at 02:03

1 Answers1

2

Read the docs

See below

num = 2.4586597040905134
num = round(num,5)
print(num)

output

2.45866
balderman
  • 22,927
  • 7
  • 34
  • 52