+ 6
How to make the output of 1.00 + 2.00 to be 3.00 instead of 3.0 or 3 in python?
15 Respuestas
+ 4
print(f"{1.00 + 2.00:.2f}")
#or
print("{:.2f}".format(1.00 + 2.00))
+ 1
+ 1
I just can figure it out
+ 1
Thank you
+ 1
But it doesn't validate it
+ 1
You mean you Can't pass tests?
+ 1
Tnx
+ 1
Eisom
use math.ceil() instead of round().
For this u first import math.
0
You don't need to worry about those zeros
0
Yes Abhay it doesn't pass tests
0
Eisom
Does it still not working after using ceil()???
0
Print("%.2f"%(1.00+2.00)) ..
This will help
0
How do you want to use this output? Assign it to a variable?
0
print("%.2f"%(1.00+2.00))
here is the solution:)
- 1
this is converting result 3.0 into 3.00 , Simply convert 3.0 to str and add another str 0 to that ,which will be 3.00 and then convert that into int,but I assume that's not what you want,also
I Don't think there is anyway to get 3.00 by adding 1.00 to 2.00
maybe someone else knows about it !