Python
(파이썬) 산술연산자를 이용한 사칙연산
코딩ABC
2023. 9. 20. 07:50
반응형
다음 코드는 파이썬의 산술연산자를 활용한 연산의 예를 보인 코드입니다.
a=int(input("a="))
b=int(input("a="))
print("%d + %d = %d" % (a, b, a+b))
print("%d - %d = %d" % (a, b, a-b))
print("%d * %d = %d" % (a, b, a*b))
print("%d / %d = %f" % (a, b, a/b))
print("%d // %d = %d" % (a, b, a//b)) #몫
print("%d %% %d = %d" % (a, b, a%b)) #나머지
print("%d ** %d = %d" % (a, b, a**b)) #제곱
(Output)
a=100
a=3
100 + 3 = 103
100 - 3 = 97
100 * 3 = 300
100 / 3 = 33.333333
100 // 3 = 33
100 % 3 = 1
100 ** 3 = 1000000
반응형