0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

PythonでHello, world!

Last updated at Posted at 2021-07-18

Python学習の第一歩、Hello, world!と表示する方法を解説します。
実行環境はWindowsを想定しています。

まずは、Pythonをインストールします。
https://www.python.org/

適当なファイルを作成します。今回はhello.pyというファイルを作成します。

コマンドプロンプトを起動して、cdコマンドを使ってファイルを作成したディレクトリに移動します。
cdコマンドについては以下の記事が参考になります。
参考:https://eng-entrance.com/windows-command-cd

hello.py
print('Hello, world!')

print関数は、カッコ内をシングルクォーテーション(')または、ダブルクォーテーション(")で囲んだ文字列を表示できます。

python hello.py

コマンドプロンプトで上記のコマンドを実行します。すると

Hello, world!

と表示されます。

また、インタラクティブシェルを使ってもHello, world!を表示できます。
インタラクティブシェルについては以下の記事が参考になります。(私が書いた記事です)
参考:https://inouelog.com/python-interactive-shell/

コマンドプロンプトで

python

と入力します。
するとインタラクティブシェルが立ち上がるので、先ほどと同じようにprint関数を使います。
Enterを押すと以下のように表示されます。

>>> print('Hello, world!')
Hello, world!

2通りの方法でHello, world!を表示させる方法を解説しました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?