Previous: Simple Python Programs

The statement print("Welcome to Python") in the program is a statement to display the greeting "Welcome to Python“

# Display two messages
print("Welcome to Python") # Statement (Action)
print("Python is fun") # Statement (Action)

The following figure is a block structure visualizing indentation.

Screenshot 2025-05-09 at 20.56.31.png

Note that the statements are entered from the first column in the new line. It would cause an error if the program is typed as follows:

The following code would raise an error because the statements are in wrong indentations.

# Display two messages
 print("Welcome to Python")
print("Python is fun") 

For example, the Python interpreter will report errors for the following code:

print("Welcome to Python").
print("Python is fun").

However, Python sill accepts semicolon ; at the end of a statement.

# Display two messages
print("Welcome to Python");
print("Python is fun");