How do I make a simple program

Create an executable Python program

To create an executable Python program (Python script), we need a file. The special thing about this file is the file extension. Here ".py" is used for Python.

It doesn't matter which operating system we work with. In the example, the “notepad” editor in the operating system is used under Windows.

The easiest way is to click on Start and then just start typing. As soon as we have typed in the first letters of "editor", we already receive the suggestion for the standard editor.

Select this editor.

And now we can type in our Python program directly in the editor.

In our text editor we enter:

Pay attention to the file extension ".py" when saving! I use “” as the filename for our first program.

I save my Python program in the folder “” under “C:”.

Now our folder should have this content:

To start the Python program

Start Python on Windows

To start the Python program, we need a DOS console. We call this up under Windows by clicking on the start button again and simply typing in "cmd". We can then use the suggested DOS console.

If the path has been correctly stored in the operating system when installing Python, you can start Python directly in the DOS console. For testing purposes, Python can be started without our written program. Simply type in “python” directly in the DOS console.

If that works, we can start our Python program "". For this purpose, the path and the file name are specified after the program has been called.

By executing the program, we now receive the output in the console of "Hello World".

If we don't want to type in the long path name, we can change to the directory once using the DOS instructions and then run the program without specifying the path. Just take a look at the following screenshot. At the beginning the program is executed with the path and then the folder "" is changed (looks like an Internet address, but you can also use it as a directory (a bit of advertising and copy protection)).

Running Python programs with the Mac OSx

On the Mac, we start the terminal. Here we have the special feature that the old version of Python is already delivered in the operating system. We can enter it directly in the terminal and receive the Python version number as a response - in the example this is "Python 2.7.10". If we have installed the current Python3, we can call it up in Terminal and receive the corresponding version number as feedback.

To start our program, we enter the path and the file name in the terminal after the start command for Python:

The program will then be executed.

Recommend • Social Bookmarks • Thank you