Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

01 Hello, World

画面に Hello, World! と出力する最初のプログラムを書く.

文字を出力する

print は,引数として渡したオブジェクト(ここでは文字列)を画面に表示する関数 (function)です.関数の詳細は P1-02 で扱います.

# 01-01. Hello, World!ノートブック
print("Hello, World!")
Hello, World!

実行すると,Hello, World! という文字列がそのまま出力されます.これが計算機からの最初の「返事」です.

コメント

Pythonでは# から行末まではコメント(comment)と呼ばれ,実行時には無視されます. 自分や他の読者へのメモとして使います.

# この行はコメント.実行されない.
print("コメントは表示されない")  # 行末コメントも書ける
コメントは表示されない

演習

Solution to Exercise 1
print("Koji Noshita")
Koji Noshita
Solution to Exercise 2
print("Hello, World!")
print("こんにちは,世界!")
print("数理生物学演習を始めます.")
Hello, World!
こんにちは,世界!
数理生物学演習を始めます.