Tech/Python
[python] 소수점 이하 자릿수 포함 출력 방법
lonnie(동현)
2020. 12. 24. 14:22
아래의 예시는 a, b, c 를 입력받고, 이들의 평균 값을 출력하는 예시이다.

여기서 만약에 a = 1, b = 2, c= 3 을 입력 받아서 출력했을 때, 값은 당연히 2.0 일 것이다.하지만, 2.00 또는 2.000 을 출력하고 싶다면?
다음과 같은 방법을 이용하면 된다.
형식 : print ( "%. 원하는 자릿수 " % 출력할 값 )

728x90
반응형