0

I have code for an assignment that returns a float, but for visual consistency I'd like to format the output in a very specific way. For example, when I call my method...

return my_variable

The unformatted output looks like,

0.00014403540291982756644

I tried using f-string to limit the output to 2 decimals.

return f'{my_variable:.2}'

For which I get,

0.00014

I know it's very odd, but I'd like the output to be,

0.00

Can this be done? Also, for the purpose of the assignment, I can only use standard Python libraries. Note, this is not a trailing zeros question like this previous question.

0 Answers0