diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index f74306aa1..b349cd8c4 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,6 +1,9 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
-exclude: static/img/
+exclude: (
+ static/img/
+ docs/05function/_samples/indent.ipynb
+ )
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
@@ -63,7 +66,7 @@ repos:
- id: nbqa-flake8
- id: nbqa-isort
- id: nbqa-mypy
- - id: nbqa-pylint
+ # - id: nbqa-pylint
- id: nbqa-pyupgrade
- id: nbqa-yapf
- id: nbqa-autopep8
diff --git a/docs/index.mdx b/docs/index.mdx
index e9235740a..f29bafb8b 100644
--- a/docs/index.mdx
+++ b/docs/index.mdx
@@ -27,3 +27,5 @@ Python やアルゴリズムについて簡単にまとめていこうかなと
10/10 練習問題を追加
10/16 練習問題をさらに追加
+
+10/23 第二週の分を執筆 [ここから](/docs/python/05function/)
diff --git a/docs/python/05function/_samples/gravitation.ipynb b/docs/python/05function/_samples/gravitation.ipynb
new file mode 100644
index 000000000..dbd52365e
--- /dev/null
+++ b/docs/python/05function/_samples/gravitation.ipynb
@@ -0,0 +1,34 @@
+{
+ "nbformat": 4,
+ "nbformat_minor": 2,
+ "metadata": {},
+ "cells": [
+ {
+ "metadata": {},
+ "source": [
+ "G = 6.7 * 10 ** (-11)\n",
+ "\n",
+ "\n",
+ "def F(r, M, m):\n",
+ " return G * M * m / r**2\n",
+ "\n",
+ "\n",
+ "F(2, 60, 20)"
+ ],
+ "cell_type": "code",
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "2.0099999999999998e-08"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 2
+ }
+ ],
+ "execution_count": null
+ }
+ ]
+}
diff --git a/docs/python/05function/_samples/hello.ipynb b/docs/python/05function/_samples/hello.ipynb
new file mode 100644
index 000000000..1c9f41c91
--- /dev/null
+++ b/docs/python/05function/_samples/hello.ipynb
@@ -0,0 +1,28 @@
+{
+ "nbformat": 4,
+ "nbformat_minor": 2,
+ "metadata": {},
+ "cells": [
+ {
+ "metadata": {},
+ "source": [
+ "def hello():\n",
+ " print(\"Hello!\")\n",
+ "\n",
+ "\n",
+ "hello()"
+ ],
+ "cell_type": "code",
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Hello!\n"
+ ]
+ }
+ ],
+ "execution_count": null
+ }
+ ]
+}
diff --git a/docs/python/05function/_samples/indent.ipynb b/docs/python/05function/_samples/indent.ipynb
new file mode 100644
index 000000000..984654f66
--- /dev/null
+++ b/docs/python/05function/_samples/indent.ipynb
@@ -0,0 +1,28 @@
+{
+ "nbformat": 4,
+ "nbformat_minor": 2,
+ "metadata": {},
+ "cells": [
+ {
+ "metadata": {},
+ "source": [
+ "def f(x):\n",
+ "return x**2\n",
+ "\n",
+ "f(2)+f(3)"
+ ],
+ "cell_type": "code",
+ "outputs": [
+ {
+ "output_type": "error",
+ "ename": "IndentationError",
+ "evalue": "expected an indented block after function definition on line 1 (3556709620.py, line 2)",
+ "traceback": [
+ "\u001b[0;36m Cell \u001b[0;32mIn [1], line 2\u001b[0;36m\u001b[0m\n\u001b[0;31m return x**2\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mIndentationError\u001b[0m\u001b[0;31m:\u001b[0m expected an indented block after function definition on line 1\n"
+ ]
+ }
+ ],
+ "execution_count": null
+ }
+ ]
+}
diff --git a/docs/python/05function/_samples/introduce_language.ipynb b/docs/python/05function/_samples/introduce_language.ipynb
new file mode 100644
index 000000000..ba5aece59
--- /dev/null
+++ b/docs/python/05function/_samples/introduce_language.ipynb
@@ -0,0 +1,28 @@
+{
+ "nbformat": 4,
+ "nbformat_minor": 2,
+ "metadata": {},
+ "cells": [
+ {
+ "metadata": {},
+ "source": [
+ "def introduce_self(name, language):\n",
+ " print(f\"\u79c1\u306e\u540d\u524d\u306f\u3001{name}\u3067\u3059\u3002{language}\u9078\u629e\u3067\u3059\u3002\")\n",
+ "\n",
+ "\n",
+ "introduce_self(\"\u6771\u5927\u592a\u90ce\", \"\u4e2d\u56fd\u8a9e\")"
+ ],
+ "cell_type": "code",
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "\u79c1\u306e\u540d\u524d\u306f\u3001\u6771\u5927\u592a\u90ce\u3067\u3059\u3002\u4e2d\u56fd\u8a9e\u9078\u629e\u3067\u3059\u3002\n"
+ ]
+ }
+ ],
+ "execution_count": null
+ }
+ ]
+}
diff --git a/docs/python/05function/_samples/introduce_language2.ipynb b/docs/python/05function/_samples/introduce_language2.ipynb
new file mode 100644
index 000000000..ee3c24bfa
--- /dev/null
+++ b/docs/python/05function/_samples/introduce_language2.ipynb
@@ -0,0 +1,28 @@
+{
+ "nbformat": 4,
+ "nbformat_minor": 2,
+ "metadata": {},
+ "cells": [
+ {
+ "metadata": {},
+ "source": [
+ "def introduce_self(name, language):\n",
+ " print(\"\u79c1\u306e\u540d\u524d\u306f\u3001\" + name + \"\u3067\u3059\u3002\" + language + \"\u9078\u629e\u3067\u3059\u3002\")\n",
+ "\n",
+ "\n",
+ "introduce_self(\"\u6771\u5927\u592a\u90ce\", \"\u4e2d\u56fd\u8a9e\")"
+ ],
+ "cell_type": "code",
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "\u79c1\u306e\u540d\u524d\u306f\u3001\u6771\u5927\u592a\u90ce\u3067\u3059\u3002\u4e2d\u56fd\u8a9e\u9078\u629e\u3067\u3059\u3002\n"
+ ]
+ }
+ ],
+ "execution_count": null
+ }
+ ]
+}
diff --git a/docs/python/05function/_samples/introduce_self.ipynb b/docs/python/05function/_samples/introduce_self.ipynb
new file mode 100644
index 000000000..5bc9dc15a
--- /dev/null
+++ b/docs/python/05function/_samples/introduce_self.ipynb
@@ -0,0 +1,28 @@
+{
+ "nbformat": 4,
+ "nbformat_minor": 2,
+ "metadata": {},
+ "cells": [
+ {
+ "metadata": {},
+ "source": [
+ "def introduce_self(name):\n",
+ " print(f\"\u79c1\u306e\u540d\u524d\u306f\u3001{name}\u3067\u3059\u3002\")\n",
+ "\n",
+ "\n",
+ "introduce_self(\"\u7530\u4e2d\")"
+ ],
+ "cell_type": "code",
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "\u79c1\u306e\u540d\u524d\u306f\u3001\u7530\u4e2d\u3067\u3059\u3002\n"
+ ]
+ }
+ ],
+ "execution_count": null
+ }
+ ]
+}
diff --git a/docs/python/05function/_samples/introduce_self2.ipynb b/docs/python/05function/_samples/introduce_self2.ipynb
new file mode 100644
index 000000000..d5be41f8b
--- /dev/null
+++ b/docs/python/05function/_samples/introduce_self2.ipynb
@@ -0,0 +1,28 @@
+{
+ "nbformat": 4,
+ "nbformat_minor": 2,
+ "metadata": {},
+ "cells": [
+ {
+ "metadata": {},
+ "source": [
+ "def introduce_self(name):\n",
+ " print(\"\u79c1\u306e\u540d\u524d\u306f\u3001\" + name + \"\u3067\u3059\u3002\")\n",
+ "\n",
+ "\n",
+ "introduce_self(\"\u7530\u4e2d\")"
+ ],
+ "cell_type": "code",
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "\u79c1\u306e\u540d\u524d\u306f\u3001\u7530\u4e2d\u3067\u3059\u3002\n"
+ ]
+ }
+ ],
+ "execution_count": null
+ }
+ ]
+}
diff --git a/docs/python/05function/_samples/introduce_self3.ipynb b/docs/python/05function/_samples/introduce_self3.ipynb
new file mode 100644
index 000000000..d3af26086
--- /dev/null
+++ b/docs/python/05function/_samples/introduce_self3.ipynb
@@ -0,0 +1,28 @@
+{
+ "nbformat": 4,
+ "nbformat_minor": 2,
+ "metadata": {},
+ "cells": [
+ {
+ "metadata": {},
+ "source": [
+ "def introduce_self(name):\n",
+ " return f\"\u79c1\u306e\u540d\u524d\u306f\u3001{name}\u3067\u3059\u3002\"\n",
+ "\n",
+ "\n",
+ "print(introduce_self(\"\u5c0f\u6797\"))"
+ ],
+ "cell_type": "code",
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "\u79c1\u306e\u540d\u524d\u306f\u3001\u5c0f\u6797\u3067\u3059\u3002\n"
+ ]
+ }
+ ],
+ "execution_count": null
+ }
+ ]
+}
diff --git a/docs/python/05function/_samples/introduce_self4.ipynb b/docs/python/05function/_samples/introduce_self4.ipynb
new file mode 100644
index 000000000..5bdf6ac92
--- /dev/null
+++ b/docs/python/05function/_samples/introduce_self4.ipynb
@@ -0,0 +1,28 @@
+{
+ "nbformat": 4,
+ "nbformat_minor": 2,
+ "metadata": {},
+ "cells": [
+ {
+ "metadata": {},
+ "source": [
+ "def introduce_self(name):\n",
+ " return \"\u79c1\u306e\u540d\u524d\u306f\u3001\" + name + \"\u3067\u3059\u3002\"\n",
+ "\n",
+ "\n",
+ "print(introduce_self(\"\u5c0f\u6797\"))"
+ ],
+ "cell_type": "code",
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "\u79c1\u306e\u540d\u524d\u306f\u3001\u5c0f\u6797\u3067\u3059\u3002\n"
+ ]
+ }
+ ],
+ "execution_count": null
+ }
+ ]
+}
diff --git a/docs/python/05function/_samples/x2.ipynb b/docs/python/05function/_samples/x2.ipynb
new file mode 100644
index 000000000..4bd48f71f
--- /dev/null
+++ b/docs/python/05function/_samples/x2.ipynb
@@ -0,0 +1,27 @@
+{
+ "nbformat": 4,
+ "nbformat_minor": 2,
+ "metadata": {},
+ "cells": [
+ {
+ "metadata": {},
+ "source": [
+ "2**2 + 3**2"
+ ],
+ "cell_type": "code",
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "13"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 1
+ }
+ ],
+ "execution_count": null
+ }
+ ]
+}
diff --git a/docs/python/05function/_samples/x2_function.ipynb b/docs/python/05function/_samples/x2_function.ipynb
new file mode 100644
index 000000000..4e505b30f
--- /dev/null
+++ b/docs/python/05function/_samples/x2_function.ipynb
@@ -0,0 +1,31 @@
+{
+ "nbformat": 4,
+ "nbformat_minor": 2,
+ "metadata": {},
+ "cells": [
+ {
+ "metadata": {},
+ "source": [
+ "def f(x):\n",
+ " return x**2\n",
+ "\n",
+ "\n",
+ "f(2) + f(3)"
+ ],
+ "cell_type": "code",
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "13"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 1
+ }
+ ],
+ "execution_count": null
+ }
+ ]
+}
diff --git a/docs/python/05function/index.mdx b/docs/python/05function/index.mdx
new file mode 100644
index 000000000..da8514fd6
--- /dev/null
+++ b/docs/python/05function/index.mdx
@@ -0,0 +1,93 @@
+---
+sidebar_position: 5
+---
+
+import ViewSource from "@site/src/components/ViewSource/ViewSource";
+import Answer from "@site/src/components/Answer";
+
+# 関数
+
+## 関数
+
+$f(x)=x^2$ としたときの、$f(2)+f(3)$ を求めてみましょう。
+
+
+
+一応できましたが、このようにつくると関数値を求めるときに毎回 $f(x)$ の定義を見て書かなければなりません。今回のように、単純な関数では良いですがもっと複雑な関数では大変です。このようなときに、Python では関数を使用できます。
+
+関数を用いると、次のように簡単にプログラムを書くことができます。
+
+
+
+関数は、次のようにしてつくることができます。引数は「ひきすう」と読みます。
+
+```python
+def 関数名(引数):
+ return 戻り値
+```
+
+関数を使用するときは、次のようにするだけです。
+
+```python
+関数名(任意の引数)
+```
+
+:::caution
+Python では、きちんとインデント(字下げ)をしないとエラーが発生してしまいます。
+例えば、先程のプログラムで `return` の前のインデントを忘れると、どこまでが関数の中身であるのかわからなくなり、次のようにエラーが発生してしまいます。
+
+
+:::
+
+プログラムにおける関数は、数学における関数よりも多くのことができます。
+例えば、数学では戻り値は必要ですが、プログラムにおける関数には戻り値は必ずしも必要ありません。そのため、次のようなプログラムをつくることができます。
+
+
+
+このようにプログラムにおいては、一連の処理を実行するときに関数を使うことができます。もちろん、引数を与えると引数に応じた処理をすることができます。
+
+
+
+:::note
+上のプログラムは、下と同じ意味です。下のプログラムでも問題ないのですが、少し格好悪いので、`f-string` を使ってしまいました。気にしないでください。
+
+`+` 記号を使うと、文字列をつなげることができます。
+
+
+:::
+
+戻り値を使うと、次のようにも表現できます。
+
+
+
+:::note
+先ほどと同様に `f-string` を使ってしまいました。`f-string` を使わないと、次のようになります。
+
+
+:::
+
+### 練習問題 1
+
+万有引力を求める関数を作って実際に計算してみましょう。
+
+$$
+F=G\frac{Mm}{r^2}
+$$
+
+$G=6.7\times 10^{-11}$、$r=2$、$M=60$、$m=20$ とします。
+
+
+
+
+
+### 練習問題 2
+
+`私の名前は、東大太郎です。中国語選択です。` のように自分の名前と第2外国語を紹介する関数を作ってみましょう。
+
+
+
+
+`f-string` を使わないと次のようになります。
+
+
+
diff --git a/docs/python/06library/_samples/ceil.ipynb b/docs/python/06library/_samples/ceil.ipynb
new file mode 100644
index 000000000..21db0a3ee
--- /dev/null
+++ b/docs/python/06library/_samples/ceil.ipynb
@@ -0,0 +1,29 @@
+{
+ "nbformat": 4,
+ "nbformat_minor": 2,
+ "metadata": {},
+ "cells": [
+ {
+ "metadata": {},
+ "source": [
+ "import math\n",
+ "\n",
+ "math.ceil(3.2)"
+ ],
+ "cell_type": "code",
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "4"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 1
+ }
+ ],
+ "execution_count": null
+ }
+ ]
+}
diff --git a/docs/python/06library/_samples/cos.ipynb b/docs/python/06library/_samples/cos.ipynb
new file mode 100644
index 000000000..38777a041
--- /dev/null
+++ b/docs/python/06library/_samples/cos.ipynb
@@ -0,0 +1,29 @@
+{
+ "nbformat": 4,
+ "nbformat_minor": 2,
+ "metadata": {},
+ "cells": [
+ {
+ "metadata": {},
+ "source": [
+ "import math\n",
+ "\n",
+ "math.cos(1)"
+ ],
+ "cell_type": "code",
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "0.5403023058681398"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 1
+ }
+ ],
+ "execution_count": null
+ }
+ ]
+}
diff --git a/docs/python/06library/_samples/exp.ipynb b/docs/python/06library/_samples/exp.ipynb
new file mode 100644
index 000000000..0f2146128
--- /dev/null
+++ b/docs/python/06library/_samples/exp.ipynb
@@ -0,0 +1,29 @@
+{
+ "nbformat": 4,
+ "nbformat_minor": 2,
+ "metadata": {},
+ "cells": [
+ {
+ "metadata": {},
+ "source": [
+ "import math\n",
+ "\n",
+ "math.exp(2)"
+ ],
+ "cell_type": "code",
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "7.38905609893065"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 1
+ }
+ ],
+ "execution_count": null
+ }
+ ]
+}
diff --git a/docs/python/06library/_samples/fabs.ipynb b/docs/python/06library/_samples/fabs.ipynb
new file mode 100644
index 000000000..507527aa3
--- /dev/null
+++ b/docs/python/06library/_samples/fabs.ipynb
@@ -0,0 +1,29 @@
+{
+ "nbformat": 4,
+ "nbformat_minor": 2,
+ "metadata": {},
+ "cells": [
+ {
+ "metadata": {},
+ "source": [
+ "import math\n",
+ "\n",
+ "math.fabs(-4)"
+ ],
+ "cell_type": "code",
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "4.0"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 1
+ }
+ ],
+ "execution_count": null
+ }
+ ]
+}
diff --git a/docs/python/06library/_samples/floor.ipynb b/docs/python/06library/_samples/floor.ipynb
new file mode 100644
index 000000000..f0b4a10a5
--- /dev/null
+++ b/docs/python/06library/_samples/floor.ipynb
@@ -0,0 +1,29 @@
+{
+ "nbformat": 4,
+ "nbformat_minor": 2,
+ "metadata": {},
+ "cells": [
+ {
+ "metadata": {},
+ "source": [
+ "import math\n",
+ "\n",
+ "math.floor(3.2)"
+ ],
+ "cell_type": "code",
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "3"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 2
+ }
+ ],
+ "execution_count": null
+ }
+ ]
+}
diff --git a/docs/python/06library/_samples/log.ipynb b/docs/python/06library/_samples/log.ipynb
new file mode 100644
index 000000000..72dbe9ef0
--- /dev/null
+++ b/docs/python/06library/_samples/log.ipynb
@@ -0,0 +1,29 @@
+{
+ "nbformat": 4,
+ "nbformat_minor": 2,
+ "metadata": {},
+ "cells": [
+ {
+ "metadata": {},
+ "source": [
+ "import math\n",
+ "\n",
+ "math.log(8, 2)"
+ ],
+ "cell_type": "code",
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "3.0"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 2
+ }
+ ],
+ "execution_count": null
+ }
+ ]
+}
diff --git a/docs/python/06library/_samples/math_example.ipynb b/docs/python/06library/_samples/math_example.ipynb
new file mode 100644
index 000000000..3a8c557a7
--- /dev/null
+++ b/docs/python/06library/_samples/math_example.ipynb
@@ -0,0 +1,29 @@
+{
+ "nbformat": 4,
+ "nbformat_minor": 2,
+ "metadata": {},
+ "cells": [
+ {
+ "metadata": {},
+ "source": [
+ "import math\n",
+ "\n",
+ "math.fabs(-2)"
+ ],
+ "cell_type": "code",
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "2.0"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 2
+ }
+ ],
+ "execution_count": null
+ }
+ ]
+}
diff --git a/docs/python/06library/_samples/pi.ipynb b/docs/python/06library/_samples/pi.ipynb
new file mode 100644
index 000000000..246a98362
--- /dev/null
+++ b/docs/python/06library/_samples/pi.ipynb
@@ -0,0 +1,29 @@
+{
+ "nbformat": 4,
+ "nbformat_minor": 2,
+ "metadata": {},
+ "cells": [
+ {
+ "metadata": {},
+ "source": [
+ "import math\n",
+ "\n",
+ "math.pi"
+ ],
+ "cell_type": "code",
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "3.141592653589793"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 4
+ }
+ ],
+ "execution_count": null
+ }
+ ]
+}
diff --git a/docs/python/06library/_samples/sin.ipynb b/docs/python/06library/_samples/sin.ipynb
new file mode 100644
index 000000000..5ae281ff3
--- /dev/null
+++ b/docs/python/06library/_samples/sin.ipynb
@@ -0,0 +1,29 @@
+{
+ "nbformat": 4,
+ "nbformat_minor": 2,
+ "metadata": {},
+ "cells": [
+ {
+ "metadata": {},
+ "source": [
+ "import math\n",
+ "\n",
+ "math.sin(1)"
+ ],
+ "cell_type": "code",
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "0.8414709848078965"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 1
+ }
+ ],
+ "execution_count": null
+ }
+ ]
+}
diff --git a/docs/python/06library/_samples/sqrt.ipynb b/docs/python/06library/_samples/sqrt.ipynb
new file mode 100644
index 000000000..34b6375b1
--- /dev/null
+++ b/docs/python/06library/_samples/sqrt.ipynb
@@ -0,0 +1,29 @@
+{
+ "nbformat": 4,
+ "nbformat_minor": 2,
+ "metadata": {},
+ "cells": [
+ {
+ "metadata": {},
+ "source": [
+ "import math\n",
+ "\n",
+ "math.sqrt(2)"
+ ],
+ "cell_type": "code",
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "1.4142135623730951"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 1
+ }
+ ],
+ "execution_count": null
+ }
+ ]
+}
diff --git a/docs/python/06library/_samples/tan.ipynb b/docs/python/06library/_samples/tan.ipynb
new file mode 100644
index 000000000..621a353e7
--- /dev/null
+++ b/docs/python/06library/_samples/tan.ipynb
@@ -0,0 +1,29 @@
+{
+ "nbformat": 4,
+ "nbformat_minor": 2,
+ "metadata": {},
+ "cells": [
+ {
+ "metadata": {},
+ "source": [
+ "import math\n",
+ "\n",
+ "math.tan(1)"
+ ],
+ "cell_type": "code",
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "1.5574077246549023"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 1
+ }
+ ],
+ "execution_count": null
+ }
+ ]
+}
diff --git a/docs/python/06library/index.mdx b/docs/python/06library/index.mdx
new file mode 100644
index 000000000..30d19ad67
--- /dev/null
+++ b/docs/python/06library/index.mdx
@@ -0,0 +1,41 @@
+---
+sidebar_position: 6
+---
+
+import ViewSource from "@site/src/components/ViewSource/ViewSource";
+import Answer from "@site/src/components/Answer";
+
+# ライブラリ
+
+## ライブラリ
+
+Python では、自分でいちいち関数を作らなくても、すでに用意されている豊富な関数群を使うことができます。(素晴らしい!)
+
+例えば、数学に関する計算をするのに便利な `math` ライブラリがあります。`math` ライブラリを使うと、様々な計算を行うことができます。
+
+例えば、絶対値を求めるには、次のようにします。
+
+
+
+`math` ライブラリを読み込むために、一行目で、
+
+```python
+import math
+```
+
+と入力します。すると、`math.関数名` のようにして関数を呼び出すことができます。
+
+`math` ライブラリにはこれ以外にも多くの関数が定義されています。その一部を紹介します。
+
+| 関数名 | 説明 | 例 |
+| ------------------ | ------------------------------------ | ------------------------------------------ |
+| `math.pi` | $\pi$ を返す。 | |
+| `math.ceil(x)` | `x` の切り上げを返す。 | |
+| `math.floor(x)` | `x` の切り捨てを返す。 | |
+| `math.fabs(x)` | `x` の絶対値を返す。 | |
+| `math.sqrt(x)` | $\sqrt{x}$ を返す。 | |
+| `math.log(x,base)` | `base` を底とする `x` の対数を返す。 | |
+| `math.exp(x)` | $e^x$ を返す。 | |
+| `math.sin(x)` | $\sin(x)$ を返す。`x` はラジアン | |
+| `math.cos(x)` | $\cos(x)$ を返す。`x` はラジアン | |
+| `math.tan(x)` | $\tan(x)$ を返す。`x` はラジアン | |
diff --git a/src/components/ViewSource/ViewSource.tsx b/src/components/ViewSource/ViewSource.tsx
index f2d72c7be..0eccb5108 100644
--- a/src/components/ViewSource/ViewSource.tsx
+++ b/src/components/ViewSource/ViewSource.tsx
@@ -37,7 +37,9 @@ export default function ViewSource({ path, nooutput = false }) {
.map((cell) =>
cell.outputs.map((output) =>
(output.text === undefined
- ? output.data["text/plain"]
+ ? output.traceback === undefined
+ ? output.data["text/plain"]
+ : output.traceback
: output.text
).join("")
)