S0-ma's Blog

s0-maのブログです。

jupyter notebookでPythonプログラミングしてみた

Abstract

jupyter notebookというPythonの実行環境で、hello worldをやってみました。

Setup and Results

jupyterのインストール

ターミナルを開いて以下のコマンドでjupyterをインストール。

pip install jupyer

インストールができたら、適当に作業ディレクトリを作成して以下を実行。

jupyter notebook

ブラウザが開くので、あとは新しくPython3のnotebookを作成するとPythonでコードが書けるようになる。

コード

print("hello world!")

実行結果

実行したいコードが書かれているセルにカーソルをあわせて、Ctrl+Enterで実行。 ブラウザ上で"hello world!" と表示された。

f:id:s0-ma:20190209180033j:plain
hello world on jupyter notebook

Conclusion

jupyterすごい。コマンドラインで実行するよりも簡単だし、何よりgithubがノートブック形式に対応しているので、やったことがgithub上でそのまま見られる。

Reference

github.com