We have successfully set up and installed a LAMP server on our Ubuntu machine, optimized our server, and now it’s time to write our first Python application. We won’t be writing anything too fancy, but we will cover the basics of a Python application, and also talk a bit to either our MySQL or PostgreSQL database.
Throughout this tutorial, I will be using the nano editor in the terminal to write my Python code, but feel free to use whichever editor you please. It should not affect the outcome of this tutorial.
Also note that unlike many popular programming languages, Python uses whitespace indentation as a delimiter for code blocks, instead of the traditional curly braces or keywords. This allows Python to have extremely readable code, and forces you not to write single-line functions. Keep this in mind as you are writing your own program, as you don’t want to have issues caused by missing line breaks or indentation.
Creating Our First .py File
Navigate to a folder that you would like to create your first Python file in, and create a file called test.py. Now open this file up in the editor and type the following code:
print “Hello, World!”
Save your file, and in the terminal, navigate to wherever you created this file, and run it by calling python test.py. You should see the correct outp