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
2 changes: 1 addition & 1 deletion docs/extras/5tex/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Windows を使っている場合は、[WSL をインストールの項](/docs/ex
<Tabs groupId="os">
<TabItem value="win-and-ubuntu" label="Windows 及び Ubuntu">

次の動画の通りにすれば、インストールできます。 VSCode でターミナルを開いている状態にしておいてください
次の動画の通りにすれば、インストールできます。 VSCode から WSL 上のターミナルを開いている状態にしておいてください

- ターミナルで次のように入力します。

Expand Down
4 changes: 2 additions & 2 deletions docs/python/02get-started/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ import Answer from "@site/src/components/Answer";

`Hello World!` と表示されましたか。

`print` は画面に文字列を表示させる命令です。`"` で括った文字列が画面に表示されます。
`print` は画面に文字列を表示させる命令です。`"` と `"` で括った文字列が画面に表示されます。

### 練習問題

先程のプログラムを少し変えて、`Hello from Python!` と出力するようなプログラムを書いてみましょう。

<Answer>

`"` で括られた文字列を `Hello World!` から次のように `Hello from Python` に変えれば、完成です。
`"` と `"` で括られた文字列を `Hello World!` から次のように `Hello from Python` に変えれば、完成です。

<ViewSource path="_samples/hello-from-python.ipynb" />
</Answer>
Expand Down
4 changes: 2 additions & 2 deletions docs/python/09multi-array/_samples/2_dim_array_revised.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"metadata": {},
"source": [
"def sum(scores):\n",
"def sum_2d(scores):\n",
" s = 0\n",
" for i in range(len(scores)):\n",
" for j in range(len(scores[i])):\n",
Expand All @@ -16,7 +16,7 @@
"\n",
"SCORES = [[83, 75, 32], [73, 53, 84], [63, 48, 64]]\n",
"\n",
"print(sum(SCORES))"
"print(sum_2d(SCORES))"
],
"cell_type": "code",
"outputs": [
Expand Down
4 changes: 2 additions & 2 deletions docs/python/09multi-array/_samples/2_dim_array_sample.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"metadata": {},
"source": [
"def sum(scores):\n",
"def sum_val(scores):\n",
" s = 0\n",
" for i in range(len(scores)):\n",
" s += scores[i]\n",
Expand All @@ -17,7 +17,7 @@
"B_SCORES = [73, 53, 84]\n",
"C_SCORES = [63, 48, 64]\n",
"\n",
"print(sum(A_SCORES) + sum(B_SCORES) + sum(C_SCORES))"
"print(sum_val(A_SCORES) + sum_val(B_SCORES) + sum_val(C_SCORES))"
],
"cell_type": "code",
"outputs": [
Expand Down
4 changes: 2 additions & 2 deletions docs/python/09multi-array/_samples/3_dim_array_sample.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"metadata": {},
"source": [
"def sum(scores):\n",
"def sum_3d(scores):\n",
" s = 0\n",
" for i in range(len(scores)):\n",
" for j in range(len(scores[i])):\n",
Expand All @@ -17,7 +17,7 @@
"\n",
"SCORES = [[[51, 56, 10], [47, 52, 58]], [[24, 92, 34], [28, 44, 19]]]\n",
"\n",
"print(sum(SCORES))"
"print(sum_3d(SCORES))"
],
"cell_type": "code",
"outputs": [
Expand Down
8 changes: 4 additions & 4 deletions docs/python/09multi-array/_samples/average_of_sum.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@
{
"metadata": {},
"source": [
"def sum(scores):\n",
"def sum_val(scores):\n",
" s = 0\n",
" for i in range(len(scores)):\n",
" s += scores[i]\n",
" return s\n",
"\n",
"\n",
"def average_sum(scores):\n",
"def sum_average(scores):\n",
" s = 0\n",
" for i in range(len(scores)):\n",
" s += sum(scores[i])\n",
" s += sum_val(scores[i])\n",
" return s / len(scores)\n",
"\n",
"\n",
"SCORES = [[83, 75, 32], [73, 53, 84], [63, 48, 64]]\n",
"\n",
"print(average_sum(SCORES))"
"print(sum_average(SCORES))"
],
"cell_type": "code",
"outputs": [
Expand Down
2 changes: 1 addition & 1 deletion docs/python/09multi-array/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ $i$ 行、$j$ 列の数字を取り出すには、次のようにします。
二次元配列をさらに発展させて、三次元配列を考えることもできます。

例えば、1 組に A と B が所属していて、2 組に C と D が所属しているとします。
その時、それぞれの生徒の国語と数学、英語の点数が次のように与えられたとします
その時、それぞれの生徒の国語と数学と英語の点数が次のように与えられたとします

1 組

Expand Down
48 changes: 22 additions & 26 deletions docs/python/10if/_samples/alcohol.ipynb
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
{
"nbformat": 4,
"nbformat_minor": 2,
"metadata": {},
"cells": [
{
"metadata": {},
"source": [
"def can_drink(age):\n",
" if age < 20:\n",
" print(\"お酒は二十歳になってから!\")\n",
"\n",
"\n",
"age = 19\n",
"can_drink(age)"
],
"cell_type": "code",
"outputs": [
"nbformat": 4,
"nbformat_minor": 2,
"metadata": {},
"cells": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"お酒は二十歳になってから!\n"
]
"metadata": {},
"source": [
"age = 19\n",
"if age < 20:\n",
" print(\"\u304a\u9152\u306f\u4e8c\u5341\u6b73\u306b\u306a\u3063\u3066\u304b\u3089\uff01\")"
],
"cell_type": "code",
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"\u304a\u9152\u306f\u4e8c\u5341\u6b73\u306b\u306a\u3063\u3066\u304b\u3089\uff01\n"
]
}
],
"execution_count": null
}
],
"execution_count": null
}
]
]
}
6 changes: 3 additions & 3 deletions docs/python/10if/_samples/max.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
{
"metadata": {},
"source": [
"def max(scores):\n",
"def max_val(scores):\n",
" m = scores[0]\n",
" for i in range(len(scores)):\n",
" for i in range(1, len(scores)):\n",
" if m < scores[i]:\n",
" m = scores[i]\n",
" return m\n",
"\n",
"\n",
"SCORES = [55, 32, 16, 51, 80, 19]\n",
"print(max(SCORES))"
"print(max_val(SCORES))"
],
"cell_type": "code",
"outputs": [
Expand Down
48 changes: 28 additions & 20 deletions docs/python/10if/_samples/the_right_to_vote.ipynb
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
{
"nbformat": 4,
"nbformat_minor": 2,
"metadata": {},
"cells": [
{
"metadata": {},
"source": [
"age = 18\n",
"if age < 18:\n",
" print(\"選挙権はありません。\")\n",
"elif age < 25:\n",
" print(\"投票することができます。\")\n",
"else:\n",
" print(\"衆議院議員に立候補することができます。\")"
],
"cell_type": "code",
"outputs": [],
"execution_count": null
}
]
"nbformat": 4,
"nbformat_minor": 2,
"metadata": {},
"cells": [
{
"metadata": {},
"source": [
"age = 18\n",
"if age < 18:\n",
" print(\"\u9078\u6319\u6a29\u306f\u3042\u308a\u307e\u305b\u3093\u3002\")\n",
"elif age < 25:\n",
" print(\"\u6295\u7968\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\")\n",
"else:\n",
" print(\"\u8846\u8b70\u9662\u8b70\u54e1\u306b\u7acb\u5019\u88dc\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\")"
],
"cell_type": "code",
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"\u6295\u7968\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\n"
]
}
],
"execution_count": null
}
]
}
13 changes: 7 additions & 6 deletions docs/python/10if/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Python では、文字列や数字以外にも論理値という真か偽かを

## 比較演算子

Python では、次のように比較演算子を用いて真偽を判定することができます。次のプログラムでは、`age > 20` が偽なので、`False` が返されています。
Python では、次のように比較演算子を用いて真偽を判定することができます。次のプログラムでは、`age > 20` が偽なので、論理値である `False` が返されています。

<ViewSource path="_samples/comparison_operator.ipynb" />

Expand Down Expand Up @@ -62,6 +62,7 @@ Python では、次のように比較演算子を用いて真偽を判定する

if 文は、次のようにして作ることができます。
条件式には、先程の比較演算子や論理演算子が使えます。
条件式を評価した結果が `True` であれば、実行されます。

```python
if 条件式:
Expand Down Expand Up @@ -96,12 +97,12 @@ else:
if ~ elif ~ else 文の構文は次のとおりです。

```python
if 条件式:
真の時の処理
elif:
偽の時である条件が真の時の処理
if 条件式1:
条件式1が真の時の処理
elif 条件式2:
条件式1が偽でかつ条件式2が真の時の処理
else:
すべてが偽の時の処理
条件式1も条件式2も偽の時の処理
```

## 練習問題
Expand Down