Python Lessons – 1.11 Using an editor

Python Lessons - 1.11 Using an editor

Programming in Python

So far we have only used the Python console by executing the commands one line at a time. But Python’s programming goes much further.

The programs are made differently, many lines of code are assembled together to respond to certain algorithms.

A series of lines of code will perform a single and specific operation, that is a function. Then more functionalization will be carried out in sequence to carry out a larger operation, ie a script.

For now let’s stop here. Scripts can be identified with a single program.

So a program in Python, will consist of a file, in which all the lines of code will be placed one after the other, with a correct syntax (and also with a good description of the commands in the comments). This file will be saved with a .py extension.

Finally, this program will run all at once using the python command via the command line.

$ python

This time it will no longer be possible to wait for the effect of each command line, see the results, insert new variables and execute the next command, unless you use the input () and print () commands. The program runs all at once, and if it will give an error in a specific line, it will be necessary to repeat the execution of the whole program and not start again from the line in question.

Using an Editor

We have already mentioned at the beginning of this first part of the Python basic course, which together with the Python installation an IDLE was installed on the computer.

An IDLE is a text editor that allows you to perform programming, ie writing programs in Python in a simple and fast.

In fact, from the same editor, you can create a new .py file, write the code, run the program, correct the errors, and save the program, to reuse it at a later time.

⇐ Go to Python Lesson 1.10 – In-place operators

Go to Python Lesson 2.1 – The Flow Control ⇒

Leave a Reply