0

How to get the next 2 digit of a number after division in python ?

13th Jun 2021, 12:02 PM
HARSHINI SREE MANDJINI
HARSHINI SREE MANDJINI - avatar
5 Réponses
+ 3
%[flags][width][.precision]type %8.2f print("%8.2f" % (1.235)) print("%8.2f" % (351.2))
13th Jun 2021, 12:11 PM
JaScript
JaScript - avatar
+ 3
Another way of formatting: "{:.2f}".format(1.234)
13th Jun 2021, 12:39 PM
Lisa
Lisa - avatar
+ 1
# modern way (using f-strings): print(f"{1.235:.2f}") # f-string general informations and comparison with older format sequence: # https://zetcode.com/JUMP_LINK__&&__python__&&__JUMP_LINK/fstring/
13th Jun 2021, 4:10 PM
visph
visph - avatar
0
Do you mean, when we get 1.23, you want to have "23"?
13th Jun 2021, 12:04 PM
Lisa
Lisa - avatar
0
If the number is 1.235 then I want 1.25 If no is 8.6 then 8.60
13th Jun 2021, 12:06 PM
HARSHINI SREE MANDJINI
HARSHINI SREE MANDJINI - avatar