# \[수학] 무작위 값, 나머지 연산

### 코드

{% code title="0\~1 사이의 무작위 값을 구할 때" %}

```
@수학 랜덤/무작위 값/수
```

{% endcode %}

{% code title="정수 중 무작위 값을 구할 때" %}

```
@수학 (값1)부터/이상 (값2)까지/이하/미만 랜덤/무작위 정수 
```

{% endcode %}

{% code title="나머지 값을 구할 때" %}

```
@수학 (값1)을 (값2)로 나눈 나머지
```

{% endcode %}

***

### 설명

무작위 값과 나머지 연산을 한 결과를 반환합니다.

`@수학 무작위 값`은 0\~1 사이의 값을 반환해요.

***

### 주의사항

* 수학 코드를 쓸 때는 앞에 `@수학`을 써야 해요.
* 난수는 실행할 때마다 값이 달라져요.
* 나머지는 정수 나눗셈 기준이에요.

***

### 파이썬 대응 코드

```
import random, math
random.random()            # 0~1
random.randint(a, b)       # a~b 정수
a % b
```

***

### 예시

{% code title="예시 코드" %}

```
# 무작위 값
@수학 랜덤 값 보여주기

# 무작위정수
@수학 1부터 10까지 랜덤 정수 보여주기

# 나머지
@수학 17을 5로 나눈 나머지 보여주기
```

{% endcode %}

{% code title="예시 코드의 결과" %}

```
0.1649935765702365
6
2
```

{% endcode %}

***

### 검색 키워드

수학, 통계, 랜덤, 난수, 무작위수, 나머지


---

# 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://codebook.horang.it/math/undefined-8.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.
