初期設定

最初の設定

Pythonのインストール

以下の手順で、Pythonのインストールを行います。

1.Python公式サイトから、Pythonパッケージをダウンロードします
2.ダウンロードしたパッケージをインストールします。
3.PowerShellでPythonを実行するときに必要となる、スクリプトの実行許可を設定します。

WindowsにPythonをインストールすると、デフォルトのインストール先は以下のようにユーザーディレクトリ内のAppData/Local/Programs/Pythonの中になります。

こちらからWindows用インストーラをダウンロードします。

最新版は3.13.7でした。詳しくはこちらのサイトなどを見てください。

VSCodeエディタ

VS Codeエディタは、マイクロソフト社がオープンソースで開発しているエディターです。公式Webサイト から無料でダウンロードして利用できます。

code.visualstudio.com

VS Codeの特筆すべき特徴が、目的に応じて好きなようにカスタマイズできることです。VS CodeにはHTMLファイルの編集などエディターとしての基本機能が最初から備わっていますが、そこに「拡張機能(Extension)」と呼ばれる機能をインストールして追加できます。

例題(Forとプリントで繰り返す)

s='hello!' #文字列 'hello!' を変数 s に代入しています。

for i in range(1,11): #i が 1 から 10 まで変化します。
 print(s * i) #文字列 s を i 回繰り返して表示します。Pythonでは文字列 × 数字で繰り返しができます。
input("Enterキーを押して終了します...")

最後のインプット文は結果の画面が消えないようにする待機の役目があります。

hello!
hello!hello!
hello!hello!hello!
hello!hello!hello!hello!
hello!hello!hello!hello!hello!
hello!hello!hello!hello!hello!hello!
hello!hello!hello!hello!hello!hello!hello!
hello!hello!hello!hello!hello!hello!hello!hello!
hello!hello!hello!hello!hello!hello!hello!hello!hello!
hello!hello!hello!hello!hello!hello!hello!hello!hello!hello!
Enterキーを押して終了します...