






You should now see the output (what it prints) of your program:

Phew! That was quite a few steps to get started, but henceforth, every time we ask you to create a new file, remember to just right-click on helloworld
on the left -> New
-> Python File
and continue the same steps to type and run as shown above.
You can find more information about PyCharm in the PyCharm Quickstart page.
Vim
- Install Vim
- Mac OS X users should install
macvim
package via HomeBrew - Windows users should download the "self-installing executable" from Vim website
- GNU/Linux users should get Vim from their distribution's software repositories, e.g. Debian and Ubuntu users can install the
vim
package.
- Mac OS X users should install
- Install jedi-vim plugin for autocompletion.
- Install corresponding
jedi
python package :pip install -U jedi
Emacs
- Install Emacs 24+.
- Mac OS X users should get Emacs from http://emacsformacosx.com
- Windows users should get Emacs from http://ftp.gnu.org/gnu/emacs/windows/
- GNU/Linux users should get Emacs from their distribution's software repositories, e.g. Debian and Ubuntu users can install the
emacs24
package.
- Install ELPY
Now let's get back to programming. There is a tradition that whenever you learn a new programming language, the first program that you write and run is the 'Hello World' program - all it does is just say 'Hello World' when you run it. As Simon Cozens1 says, it is the "traditional incantation to the programming gods to help you learn the language better."
Start your choice of editor, enter the following program and save it as hello.py
.
If you are using PyCharm, we have already discussed how to run from a source file.
For other editors, open a new file hello.py
and type this:
print("hello world")
Where should you save the file? To any folder for which you know the location of the folder. If you don't understand what that means, create a new folder and use that location to save and run all your Python programs:
/tmp/py
on Mac OS X/tmp/py
on GNU/LinuxC:\py
on Windows
To create the above folder (for the operating system you are using), use the mkdir
command in the terminal, for example, mkdir /tmp/py
.
IMPORTANT: Always ensure that you give it the file extension of .py
, for example, foo.py
.
To run your Python program:
- Open a terminal window (see the previous Installation chapter on how to do that)
- Change directory to where you saved the file, for example,
cd /tmp/py
- Run the program by entering the command
python hello.py
. The output is as shown below.
$ python hello.pyhello world

If you got the output as shown above, congratulations! - you have successfully run your first Python program. You have successfully crossed the hardest part of learning programming, which is, getting started with your first program!
In case you got an error, please type the above program exactly as shown above and run the program again. Note that Python is case-sensitive i.e. print
is not the same as Print
- note the lowercase p
in the former and the uppercase P
in the latter. Also, ensure there are no spaces or tabs before the first character in each line - we will see why this is important later.
How It Works
A Python program is composed of statements. In our first program, we have only one statement. In this statement, we call the print
statement to which we supply the text "hello world".
In case you need to get help for operators like return
, then you need to put those inside quotes such as help('return')
so that Python doesn't get confused on what we're trying to do.
You should now be able to write, save and run Python programs at ease.
Now that you are a Python user, let's learn some more Python concepts.
최근 덧글