
Pythonで簡単なプログラムを書いてみよう
いよいよPythonでプログラムを書いて、書いたプログラムを実行するまでのプロセスをやっていきます。
Pythonで簡単なプログラムを書く
まず、この世の中で最も有名なプログラム「Hello World!」を書いてみます。
「Hello World!」というプログラムは、ただ画面に「Hello World!」と表示させるだけのプログラムですが、どんなプログラム言語を学んでいくときも、まずはじめに実践するプログラムのことです。
プログラムを作る
Atomを起動します

Finderを起動させて[アプリケーション]をクリックします。[Atom]をダブルクリックして、Atomを起動します。
Python形式で保存する

メニューから[ファイル]をクリックし、表示された項目から[新規ファイル]をクリックします。

メニューから[ファイル]をクリックし、表示された項目から[保存]をクリックします。

名前欄に[sample.py]と入力し、場所に[書類]を選択して[保存]をクリックします。
コードを書き始める前に[.py]拡張子で保存することで、Pythonに対応した予測入力機能が有効になるので、Atomでの記述が楽になります。
プログラムを書いて保存する
実際にプログラムを書いていきます。
以下のように記述します。
print("Hello, World!")

メニューから[ファイル]をクリックし、表示された項目から[保存]をクリックして上書き保存します。

プログラムを実行する
ターミナルを起動します

Finderを起動して[アプリケーション]をクリックします。
[ユーティリティ]をクリックして表示された一覧から[ターミナル]をダブルクリックします。
ファイルを読み込んで実行する
以下のように入力し[Enter]キーを押します。
python3 Documents/sample.py

ここまでの工程に誤りがなければ[Hello, World!]と表示されます。
