포스트

[Python] Baekjun No. 10869 - Four arithmetic operations

We have summarized the solution for outputting the results of four arithmetic operations using Python's arithmetic operations and string formatting.

한국어 원문은 여기에서 볼 수 있습니다.
[Python] Baekjun No. 10869 - Four arithmetic operations

BaekJoon 10869

Solution

1
2
3
4
a, b = input().split()
a, b = int(a), int(b)

print("%d\n%d\n%d\n%d\n%d" % (a+b, a-b, a*b, a/b, a%b))

Using string formatting (% operator)

"문자열" % (값들): The values following the same placeholder as %d, %f in the string are entered in order.