Python 알고리즘 - 사칙연산

Code_Alpacat·2022년 1월 2일
0

Python 알고리즘

목록 보기
2/15

사칙연산

입출력에 여러가지 방법을 적용해 풀어보겠다.

1. map + print

A, B = map(int, input().split(" "))

print(A+B)
print(A-B)
print(A*B)
print(A//B)
print(A%B)

2. map + 함수(def)

A, B = map(int, input().split(" "))

def operation(A, B):
    print(A+B, A-B, A*B, A//B, A%B, end="\n")
    
operation(A, B)

짧은 문에서는 print를 사용하는 것도 좋지만, 기왕이면 함수를 이용하는 것이 객체지향적으로 프로그래밍을 하는 좋은 연습이 될 것이다.

profile
In the future, I'm never gonna regret, cuz I've been trying my best for every single moment.

0개의 댓글