Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,23 @@ exclude: (
docs/05function/_samples/indent.ipynb
)
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
- repo: https://github.com/datarootsio/databooks
rev: 1.2.3
hooks:
- id: check-added-large-files
- id: check-json
- id: pretty-format-json
args: [--autofix]
- id: check-merge-conflict
- id: check-toml
- id: check-xml
- id: check-yaml
- id: debug-statements
- id: detect-aws-credentials
args: [--allow-missing-credentials]
- id: detect-private-key
- id: end-of-file-fixer
- id: no-commit-to-branch
args: [--branch, main]
- id: requirements-txt-fixer
- id: trailing-whitespace
- id: databooks-meta
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.3
hooks:
- id: prettier
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v8.26.0
hooks:
- id: eslint
- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: black
- id: black-jupyter
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v8.26.0
hooks:
- id: eslint
- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
hooks:
Expand All @@ -55,10 +39,6 @@ repos:
hooks:
- id: markdownlint
args: [-r, ~MD033]
- repo: https://github.com/datarootsio/databooks
rev: 1.2.3
hooks:
- id: databooks-meta
- repo: https://github.com/nbQA-dev/nbQA
rev: 1.5.3
hooks:
Expand All @@ -71,3 +51,23 @@ repos:
- id: nbqa-yapf
- id: nbqa-autopep8
- id: nbqa-pydocstyle
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-added-large-files
- id: check-json
- id: pretty-format-json
args: [--autofix]
- id: check-merge-conflict
- id: check-toml
- id: check-xml
- id: check-yaml
- id: debug-statements
- id: detect-aws-credentials
args: [--allow-missing-credentials]
- id: detect-private-key
- id: end-of-file-fixer
- id: no-commit-to-branch
args: [--branch, main]
- id: requirements-txt-fixer
- id: trailing-whitespace
29 changes: 29 additions & 0 deletions docs/python/06library/_samples/e.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"nbformat": 4,
"nbformat_minor": 2,
"metadata": {},
"cells": [
{
"metadata": {},
"source": [
"import math\n",
"\n",
"math.e"
],
"cell_type": "code",
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"2.718281828459045"
]
},
"metadata": {},
"execution_count": 1
}
],
"execution_count": null
}
]
}
30 changes: 30 additions & 0 deletions docs/python/06library/_samples/sin_pi.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"nbformat": 4,
"nbformat_minor": 2,
"metadata": {},
"cells": [
{
"metadata": {},
"source": [
"import math\n",
"\n",
"PI = math.pi\n",
"math.sin(PI / 2)"
],
"cell_type": "code",
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"1.0"
]
},
"metadata": {},
"execution_count": 1
}
],
"execution_count": null
}
]
}
32 changes: 32 additions & 0 deletions docs/python/06library/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,35 @@ import math
| `math.sin(x)` | $\sin x$ を返す。`x` はラジアン | <ViewSource path="_samples/sin.ipynb" /> |
| `math.cos(x)` | $\cos x$ を返す。`x` はラジアン | <ViewSource path="_samples/cos.ipynb" /> |
| `math.tan(x)` | $\tan x$ を返す。`x` はラジアン | <ViewSource path="_samples/tan.ipynb" /> |

`math` ライブラリには、この他にもさまざまな使い方があるので調べてみましょう。

`math` ライブラリ以外のライブラリについても調べてみましょう。

:::note 調べ方
まず、やりたいことを[Google](https://www.google.co.jp/)や[Yahoo Japan!](https://www.yahoo.co.jp/)、[Bing](https://www.bing.com/?cc=jp)などの検索エンジンを用いて調べてみましょう。Python に関する情報は豊富にあるので、きっと見つかるはずです。そこで、どのような方法を使えば良いのかわかったら、公式のドキュメントを読んで詳しい使い方を学びましょう。インターネットには古い情報や間違った情報も多くあるので、公式ドキュメントを読むとよく分かることも多いです。

Python の公式ドキュメントは、<https://docs.python.org/ja/3/>を見ると良いでしょう。
:::

### 練習問題 1

`math` ライブラリを使用して、$\sin \frac{\pi}{2}$ の値を計算してみましょう。

<Answer>
<ViewSource path="_samples/sin_pi.ipynb" />
</Answer>

### 練習問題 2

`math` ライブラリを使用して、自然対数の底 $e$ の値を出力してみましょう。

ヒント:この資料の説明だけでは作れません。自分で調べてみましょう。

<Answer>

`math` ライブラリの[公式ドキュメント](https://docs.python.org/ja/3/library/math.html#constants)に使い方が載っています。
`math.e` とすれば、自然対数の底を取得することができます。

<ViewSource path="_samples/e.ipynb" />
</Answer>