Loading [MathJax]/jax/output/HTML-CSS/fonts/TeX/fontdata.js

How to write and run your very first program 1

It is now time to write and run your first Python 3 program. It will be very simple, for now. 

The first step is to create a new source file and fill it with coe. Click File in the IDLE menu and choose New File

As you can see, IDLE opens a new window for you. You can use it to write and amend your code. 

This is the editor window. It's only purpose is to be a workplace in which your source code is treated. Do not confuse the editor window with the shell window. They perform different functions. 

The editor window is currently untitled, but it's good practice to start work by naming the source file. 

Click File (in the new window), then click Save as..., select a folder for the enw file (the desktop is a good place for your first programming attempts) and chose a name for the new file. 

Note: don't set any extension for the file name you are going to use. Python needs its files to have the .py extension, so you should rely on the dialog window's defaults. Using the standard .py extension enables the OS to properly open these files. 

 

How to write and run your very first program 2

Now put just one line into your newly opened and named editor window. 

The line looks like this: 

print("Hisssss...")

You can use the clipboard to copy the text into the file. 

We're not going to explain the meaning of the program right now. You'll find a detailed discussion in the next chapter. 

Take a closer look at the quotation marks. These are the simplest form of quotation marks (neutral, straight, dumb, etc. ) commonly used in source files. Do not try to use typographic quotes (curved, curly, smart, etc.), used by advanced text processors, as Python doesn't accept them. 

Save the file (File->Save) and run the program (Run->Run Module).

If everything goes okay and there are no mistakes in the code. the console window will show you the effects caused by running the program. 

in this case, the program hisses.

Try to run it once again. And once more. 

Now close both windows now and return to the desktop.