From 5180a74ce7186f7817612ca2a861c923c17ed221 Mon Sep 17 00:00:00 2001 From: chvmvd Date: Fri, 11 Nov 2022 23:53:44 +0900 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/extras/5tex/index.mdx | 2 +- docs/python/02get-started/index.mdx | 4 +- .../_samples/2_dim_array_revised.ipynb | 4 +- .../_samples/2_dim_array_sample.ipynb | 4 +- .../_samples/3_dim_array_sample.ipynb | 4 +- .../_samples/average_of_sum.ipynb | 8 ++-- docs/python/09multi-array/index.mdx | 2 +- docs/python/10if/_samples/alcohol.ipynb | 48 +++++++++---------- docs/python/10if/_samples/max.ipynb | 6 +-- .../10if/_samples/the_right_to_vote.ipynb | 48 +++++++++++-------- docs/python/10if/index.mdx | 13 ++--- 11 files changed, 74 insertions(+), 69 deletions(-) diff --git a/docs/extras/5tex/index.mdx b/docs/extras/5tex/index.mdx index 8b26269dc..4c1492160 100644 --- a/docs/extras/5tex/index.mdx +++ b/docs/extras/5tex/index.mdx @@ -20,7 +20,7 @@ Windows を使っている場合は、[WSL をインストールの項](/docs/ex -次の動画の通りにすれば、インストールできます。 VSCode でターミナルを開いている状態にしておいてください。 +次の動画の通りにすれば、インストールできます。 VSCode から WSL 上のターミナルを開いている状態にしておいてください。 - ターミナルで次のように入力します。 diff --git a/docs/python/02get-started/index.mdx b/docs/python/02get-started/index.mdx index 5299b06f8..037b41934 100644 --- a/docs/python/02get-started/index.mdx +++ b/docs/python/02get-started/index.mdx @@ -17,7 +17,7 @@ import Answer from "@site/src/components/Answer"; `Hello World!` と表示されましたか。 -`print` は画面に文字列を表示させる命令です。`"` で括った文字列が画面に表示されます。 +`print` は画面に文字列を表示させる命令です。`"` と `"` で括った文字列が画面に表示されます。 ### 練習問題 @@ -25,7 +25,7 @@ import Answer from "@site/src/components/Answer"; -`"` で括られた文字列を `Hello World!` から次のように `Hello from Python` に変えれば、完成です。 +`"` と `"` で括られた文字列を `Hello World!` から次のように `Hello from Python` に変えれば、完成です。 diff --git a/docs/python/09multi-array/_samples/2_dim_array_revised.ipynb b/docs/python/09multi-array/_samples/2_dim_array_revised.ipynb index a15276a6e..faf8d2638 100644 --- a/docs/python/09multi-array/_samples/2_dim_array_revised.ipynb +++ b/docs/python/09multi-array/_samples/2_dim_array_revised.ipynb @@ -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", @@ -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": [ diff --git a/docs/python/09multi-array/_samples/2_dim_array_sample.ipynb b/docs/python/09multi-array/_samples/2_dim_array_sample.ipynb index 27bfd04e0..a4c18aa8f 100644 --- a/docs/python/09multi-array/_samples/2_dim_array_sample.ipynb +++ b/docs/python/09multi-array/_samples/2_dim_array_sample.ipynb @@ -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", @@ -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": [ diff --git a/docs/python/09multi-array/_samples/3_dim_array_sample.ipynb b/docs/python/09multi-array/_samples/3_dim_array_sample.ipynb index 9496868c0..3244414d1 100644 --- a/docs/python/09multi-array/_samples/3_dim_array_sample.ipynb +++ b/docs/python/09multi-array/_samples/3_dim_array_sample.ipynb @@ -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", @@ -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": [ diff --git a/docs/python/09multi-array/_samples/average_of_sum.ipynb b/docs/python/09multi-array/_samples/average_of_sum.ipynb index e407dc96b..eeef12e92 100644 --- a/docs/python/09multi-array/_samples/average_of_sum.ipynb +++ b/docs/python/09multi-array/_samples/average_of_sum.ipynb @@ -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": [ diff --git a/docs/python/09multi-array/index.mdx b/docs/python/09multi-array/index.mdx index b3424100f..ebe716780 100644 --- a/docs/python/09multi-array/index.mdx +++ b/docs/python/09multi-array/index.mdx @@ -48,7 +48,7 @@ $i$ 行、$j$ 列の数字を取り出すには、次のようにします。 二次元配列をさらに発展させて、三次元配列を考えることもできます。 例えば、1 組に A と B が所属していて、2 組に C と D が所属しているとします。 -その時、それぞれの生徒の国語と数学、英語の点数が次のように与えられたとします。 +その時、それぞれの生徒の国語と数学と英語の点数が次のように与えられたとします。 1 組 diff --git a/docs/python/10if/_samples/alcohol.ipynb b/docs/python/10if/_samples/alcohol.ipynb index dc1fcaab5..0040bf0db 100644 --- a/docs/python/10if/_samples/alcohol.ipynb +++ b/docs/python/10if/_samples/alcohol.ipynb @@ -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 - } - ] + ] } diff --git a/docs/python/10if/_samples/max.ipynb b/docs/python/10if/_samples/max.ipynb index f936f361f..a9b02389e 100644 --- a/docs/python/10if/_samples/max.ipynb +++ b/docs/python/10if/_samples/max.ipynb @@ -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": [ diff --git a/docs/python/10if/_samples/the_right_to_vote.ipynb b/docs/python/10if/_samples/the_right_to_vote.ipynb index 1e1eaccf6..46461e933 100644 --- a/docs/python/10if/_samples/the_right_to_vote.ipynb +++ b/docs/python/10if/_samples/the_right_to_vote.ipynb @@ -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 + } + ] } diff --git a/docs/python/10if/index.mdx b/docs/python/10if/index.mdx index 7541cd3a5..e9e2ba1a4 100644 --- a/docs/python/10if/index.mdx +++ b/docs/python/10if/index.mdx @@ -19,7 +19,7 @@ Python では、文字列や数字以外にも論理値という真か偽かを ## 比較演算子 -Python では、次のように比較演算子を用いて真偽を判定することができます。次のプログラムでは、`age > 20` が偽なので、`False` が返されています。 +Python では、次のように比較演算子を用いて真偽を判定することができます。次のプログラムでは、`age > 20` が偽なので、論理値である `False` が返されています。 @@ -62,6 +62,7 @@ Python では、次のように比較演算子を用いて真偽を判定する if 文は、次のようにして作ることができます。 条件式には、先程の比較演算子や論理演算子が使えます。 +条件式を評価した結果が `True` であれば、実行されます。 ```python if 条件式: @@ -96,12 +97,12 @@ else: if ~ elif ~ else 文の構文は次のとおりです。 ```python -if 条件式: - 真の時の処理 -elif: - 偽の時である条件が真の時の処理 +if 条件式1: + 条件式1が真の時の処理 +elif 条件式2: + 条件式1が偽でかつ条件式2が真の時の処理 else: - すべてが偽の時の処理 + 条件式1も条件式2も偽の時の処理 ``` ## 練習問題