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
7 changes: 5 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ Python やアルゴリズムについて簡単にまとめていこうかなと
10/10 練習問題を追加

10/16 練習問題をさらに追加

10/23 第二週の分を執筆 [ここから](/docs/python/05function/)
34 changes: 34 additions & 0 deletions docs/python/05function/_samples/gravitation.ipynb
Original file line number Diff line number Diff line change
@@ -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
}
]
}
28 changes: 28 additions & 0 deletions docs/python/05function/_samples/hello.ipynb
Original file line number Diff line number Diff line change
@@ -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
}
]
}
28 changes: 28 additions & 0 deletions docs/python/05function/_samples/indent.ipynb
Original file line number Diff line number Diff line change
@@ -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
}
]
}
28 changes: 28 additions & 0 deletions docs/python/05function/_samples/introduce_language.ipynb
Original file line number Diff line number Diff line change
@@ -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
}
]
}
28 changes: 28 additions & 0 deletions docs/python/05function/_samples/introduce_language2.ipynb
Original file line number Diff line number Diff line change
@@ -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
}
]
}
28 changes: 28 additions & 0 deletions docs/python/05function/_samples/introduce_self.ipynb
Original file line number Diff line number Diff line change
@@ -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
}
]
}
28 changes: 28 additions & 0 deletions docs/python/05function/_samples/introduce_self2.ipynb
Original file line number Diff line number Diff line change
@@ -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
}
]
}
28 changes: 28 additions & 0 deletions docs/python/05function/_samples/introduce_self3.ipynb
Original file line number Diff line number Diff line change
@@ -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
}
]
}
28 changes: 28 additions & 0 deletions docs/python/05function/_samples/introduce_self4.ipynb
Original file line number Diff line number Diff line change
@@ -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
}
]
}
27 changes: 27 additions & 0 deletions docs/python/05function/_samples/x2.ipynb
Original file line number Diff line number Diff line change
@@ -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
}
]
}
31 changes: 31 additions & 0 deletions docs/python/05function/_samples/x2_function.ipynb
Original file line number Diff line number Diff line change
@@ -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
}
]
}
Loading