https://www.acmicpc.net/problem/5355
# 화성 수학
import sys
input = sys.stdin.readline
T = int(input().rstrip())
result = 0
for _ in range(T):
op = input().rstrip().split() # 한 줄을 리스트로 받아옴
for i in op:
if i == '@':
result *= 3
elif i == '%':
result += 5
elif i == '#':
result -= 7
else: # 숫자일 때
result = float(i)
print("{:.2f}".format(result))
result = 0 # 출력이 끝난 결과 초기화
- import sys
input = sys.stdin.readline 을 이용해 한 줄을 리스트로 받아온다.- "{:.2f}".format(result) 말고도 print(round(result, 3)) 같은 방법으로 소수점 자리수 제한을 둘 수 있다.