# 백준 알고리즘 1000번 정수 입력받아 출력하기

## 문제

> 두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오.

내가 푼 방식

```python
# 입력받은 것을 a와 b로 나눈다
# input에 split을 사용하면 입력값을 공백을 기준으로 분리 변수에 순서대로 저장
# 1 2 라고 입력했다면 a = 1 b = 2 라고 저장함
a,b = input().split() 
# a와 b는 정수다. 영어로 integer, 파이썬에서는 int라고 표현
a = int(a)
b = int(b)
# 정수값 a와 b를 출력한다
print(a + b)
```

{% hint style="info" %}
각 변수를 int 자료형으로 변환하지 않는다면 아래와 같이 출력하는 방법도 있다

`print(int(a) + int(b))`
{% endhint %}

그런데 만약 변수가 a, b 두개가 아니라 엄청 많다면?

```
a = int(a)
b = int(b)
c = int(c)
.
.
.
```

손이 아플것이다

## 배우신 분들이 쓰는 방법

### map <a href="#map" id="map"></a>

```python
#공백으로 구분한 입력값을 a와 b에 정수 자료형으로 나누어 저장
a, b = map( int, input().split() )
print(a + b)
```

## 알아두면 좋은것 <a href="#undefined" id="undefined"></a>

### 콤마로 구분한 입력값 처리 <a href="#undefined" id="undefined"></a>

```
a, b = map( int, input().split(',') ) # 입력받은 값을 콤마 기준으로 분리, 당연히 입력시 1,2와 같이 콤마로 입력값을 구분해야 작동
print(a + b)
```

### &#x20;<a href="#undefined" id="undefined"></a>

### 나눗셈의 몫과 나머지 반환 <a href="#undefined" id="undefined"></a>

나눗셈 몫을 반환하는 **//** 연산자

```python
print(7 // 4)
1 #몫이다
```

나눗셈 나머지를 반환하는 **%** 연산자

```python
print(5 % 2)
1 #나머지다
print(3 % 7)
3 #나머지다
```

몫과 나머지가 모두 나오는 */* 연산자

```python
print(5 / 4)
1.25
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jihwan.gitbook.io/life101/undefined/1000.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
