- input() : 사용자로부터 입력 받기, 입력한 값 문자열로 반환
- int(input()) : 반환된 문자열 정수형을 바꾸기
- a.split() : 여러개의 입력값 받았을 때 공백으로 구분하기
- map() : A,B값 한꺼번에 int함수 적용하기
[map함수 사용 시]
A,B = map(int, input().split())
print = (A+B)
[map함수 사용 안할 때]
A,B = input().split()
a = int(A)
b = int(B)
print(a+b)
- 조건 (0 < A,B <10) 만족시키기
class exp(Exception):
def _str_(self):
return "잘못된 식입니다."
def plus():
a,b = map(int, input().split())
if not 0 < a 10 or not 0 < b < 10:
raise exp()
print(a+b)
try:
plus()
except exp as o:
print(o)
문제
https://www.acmicpc.net/problem/1000
'백준' 카테고리의 다른 글
2720번 / 세탁소 사장 동력 / 파이썬 (2) | 2024.08.28 |
---|---|
110005번 / 파이썬 / 진법 변환 2 (0) | 2024.08.27 |
2745번 | 진법변환 | 파이썬 (0) | 2024.08.20 |
10789번 세로읽기 파이썬 (0) | 2024.08.15 |
2675번 / 문자열 반복 / 파이썬 (0) | 2024.08.10 |