-3
a=int(input())
b=float(input())
c=a/b
print(format."c{:.2f})

I am not getting.

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
  • Does this answer your question? [Limiting floats to two decimal points](https://stackoverflow.com/questions/455612/limiting-floats-to-two-decimal-points) – K Rinish Feb 23 '23 at 09:44

2 Answers2

0

This should do the trick neatly.

a=int(input())
b=float(input())
c=a/b
print(round(c,2))
0

This is a pretty old issue with floating point numbers, the round builtin function doesn't perform as expected, hence you can use these format specifiers corrected from the one in your code.

a=int(input())
b=float(input())
c=a/b
print(float(f"{c:.2f}"))

Here, you are specifying the float format for the variable c and inside the parentheses we use f to specify its formatted and inside curly braces we give the variable c and restricting it to .2f i.e 2 digits after the decimal.

S.B
  • 13,077
  • 10
  • 22
  • 49
K Rinish
  • 47
  • 1
  • 2
  • 9