W3schools Sign Up
Python Tutorial

Python Syntax

Execute Python Syntax

Python syntax can be executed by writing directly in the Command Line, or by creating a python file on the server, using the .py file extension, and running it in the Command Line.

Example

print("Hello, World!")

Python Indentation

Indentation refers to the spaces at the beginning of a code line. Where in other languages the indentation in code is for readability only, in Python the indentation is very important — Python uses indentation to indicate a block of code.

Example

if 5 > 2: print("Five is greater than two!")

Comments

Python has commenting capability for the purpose of in-code documentation. Comments start with a #, and Python will render the rest of the line as a comment.