# 복소수형(Complex)

Python의 자료형을 접하게 될 때 가장 큰 놀라움은 기본적으로 복소수형 자료형을 지원하는 것에 있습니다. C, Java와 같은 전통적으로 강자인 개발 언어에서는 복소수 사용을 위해서 별도의 라이브러리를 사용해야 하지만, Python은 그러한 수고 없이도 복잡한 수학 연산을 위한 복소수 사용이 가능합니다.

```python
var_comp = 3+2j
print(var_comp, type(var_comp))

print(var_comp.real, var_comp.imag)
print(var_comp.conjugate())
```

특수한 부분의 수치 계산이 아니라면 일반적인 프로그래밍에서 복소수형 자료를 다루는 경우는 없을 겁니다. 다만, 복소수형 자료를 지원하고 있다는 정도는 기억하고 있는 것이 좋습니다.

1행에 보면 복소수형 자료를 대입하는 형태에 대해서 알 수 있습니다. 복소수형을 대입할 경우에는 실수+허수j로 표시합니다. j를 붙여서 허수부로 표현하는 거죠. 위의 예제에서는 실수+허수j로 사용하였지만, 허수j+실수 형태로 입력하여도 문제가 되지 않습니다.

4행은 복소수형 변수인 var\_comp에 대한 실수부와 허수부를 각각 출력하는 방법을 보여줍니다. 복소수형 변수.real과 복소수형 변수.imag는 각각 실수부와 허수부만 취해서 볼 수 있도록 해줍니다.

5행은 var\_comp.conjugateI()는 var\_comp의 켤레복소수(크기는 같으나 방향은 다릅니다.)를 구해줍니다. 켤레 복소수에 관해서는 수학의 정석 등에서 살펴보시기 바랍니다.


---

# 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://study-code.gitbook.io/python-basic/untitled/complex.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.
