Get started learning Python with DataCamp's free Intro to Python tutorial. Learn Data Science by completing interactive coding challenges and watching videos by expert instructors. Start Now!

This site is generously supported by DataCamp. DataCamp offers online interactive Python Tutorials for Data Science. Join 11 million other learners and get started learning Python for data science today!

Good news! You can save 25% off your Datacamp annual subscription with the code LEARNPYTHON23ALE25 - Click here to redeem your discount

こんにちは、世界!


Pythonは非常にシンプルな言語であり、その構文は非常にわかりやすいです。プログラマが余計なコードなしでプログラムを作成することを奨励します。Pythonで最も簡単な命令は「print」命令です - これは単に行を出力します(Cとは異なり、改行も含まれます)。

Pythonのバージョンには、主にPython 2とPython 3の2つがあります。Python 2と3はかなり異なります。このチュートリアルでは、よりセマンティックに正しく、新しい機能をサポートしているPython 3を使用します。

例えば、Python 2と3の違いの一つはprintステートメントです。Python 2では、「print」ステートメントは関数ではないため、括弧なしで呼び出されます。しかし、Python 3では関数であり、括弧付きで呼び出す必要があります。

Python 3で文字列を出力するには、次のように書きます:

print("This line will be printed.")

インデント

Pythonはブロックに中括弧の代わりにインデントを使用します。タブとスペースの両方がサポートされていますが、標準のインデントは標準のPythonコードで4つのスペースを使用する必要があります。例えば:

x = 1
if x == 1:
    # 4つのスペースでインデントされています
    print("x is 1.")

Exercise

"Hello, World!"という行を表示するために"print"関数を使用してください。

print("Goodbye, World!") print("Hello, World!") test_output_contains("Hello, World!") success_msg('Great job!')

This site is generously supported by DataCamp. DataCamp offers online interactive Python Tutorials for Data Science. Join over a million other learners and get started learning Python for data science today!

Next Tutorial Take the Test
Copyright © learnpython.org. Read our Terms of Use and Privacy Policy