Hello World! Program

The “Hello world” program is a classic in computer programming, typically to display the syntax and characteristics of a given language. Python is a very simple language, and has a very straightforward syntax. The Hello World program can be written as follows:
            print("Hello world!")            

print() is a function that tells Python to display or output whatever we put in the parentheses. By default, this will output to the current interpreter window. Some functions, like the print() function, are built-in functions included in Python by default. These built-in functions are always available to use in programs that you create. Printing a string requires the word or sequence of characters to be enclosed quotation marks.

There are various ways to edit/run Python code. 

First, you will need to install Python. You can visit the official Python website and download the latest version there. Once this is installed, you are ready to create your first program.

1. Python Interpreter

The Python Interpreter is part of what is installed when you download Python. It can typically be found by searching “Python” in the Windows search bar (or by looking in the applications folder on your Mac).
Once you launch this program, it will display this screen:

You can start typing code directly into this. Just type print("Hello world") and hit enter, and it should display the output directly under the line you just typed, like below

2. IDLE

IDLE is an integrated development environment for Python. In our case, it can be used in the same way as the Python interpreter is. This is part of what is installed when you download Python. It can typically be found by searching “Python” in the Windows search bar)
After opening IDLE, you should be able to execute the code the same way as the interpreter. Here is what it should look like

3. Command Prompt or Terminal

Executing code from the command prompt (or Terminal if you’re using macOS) is just as simple. Like we’ve seen before, you can simply type print(“Hello world”) straight into the program. The only difference is that you must type “Python” into the shell first so that Windows knows what to reference. The full code can be seen below

4. Various IDEs (PyCharm, Spyder, Atom, PyDev, etc)

There are numerous IDEs that can help make editing and running Python easier for beginners. The one I currently use is Atom, so this is likely what will appear in many of my examples. You can download Atom from their website. I like Atom because it makes programming easier with things like text highlighting, autocomplete, and more. While it is considered a text editor, there are some downloadable packages that allow you to run programs. The package that I have installed is called Script. To run a program using Script, simply press Ctrl+Shift+B (or cmd+i for Mac).







Comments

  1. As I mentioned in my last post Python is a very popular language. It is very easy to see why this is the case with the simplicity of getting the program up and running. Unlike other programs where you have a large download and have to jump through hoops to find a working compiler, Python seems pretty much like a plug and play. That paired with the simple syntax of the language just puts it ahead of many other languages that end up being more of a pain for someone like an intro programmer.

    ReplyDelete
    Replies
    1. Exactly! Python is known not only for it's readability and ease of programming, but it's simplicity in setup. This is a huge reason as to why it's so widely used by schools and businesses. It only takes a few simple steps to get it running. Additionally, it is easy to run on an online compiler, which makes it more accessible.

      Delete

Post a Comment

Popular Posts