728x90
풀이
첫째 줄에 양의 정수 A
둘째 줄에 연산자 + 또는 *
셋째 줄에 양의 정수 B가 주어진다.
첫째 줄에 결과가 나오면 된다.
연산자 Y는 str으로 받으면 된다.
A = int(input())
Y = input()
B = int(input())
Y가 *일 경우 > A*B
Y가 +일 경우 > A+B
if문으로 각 경우를 나누고 print하면 된다.
코드
A = int(input())
Y = input()
B = int(input())
if Y == '*':
print(A*B)
elif Y == '+':
print(A+B)
728x90
'🥧 Python > ⚙️ 코딩테스트' 카테고리의 다른 글
[백준-Python] 11653번: 소인수분해 (0) | 2023.02.15 |
---|---|
[백준-Python] 9498번: 시험 성적 (0) | 2023.02.15 |
[백준-Python] 2675번: 문자열 반복 (0) | 2023.02.15 |
[백준-Python] 5355번: 화성 수학 (0) | 2023.02.15 |
[백준-Python] 2914번: 저작권 (0) | 2023.02.15 |