Python Guide

What's Python

Python is an interpreted, interactive and object-oriented programming language. It is completely free, it is released in open source, as free software, and therefore it can be used freely. The language is managed by the Python Software Foundation.

How to program in Python

Python is a pseudocompiled programming language.

The programmer writes the program source to a text file with a .py extension.

While the code is being written, the programmer can check the operation of the source program using the language interpreter.

Note. Python is an interpreted language. The source code is executed directly by the interpreter software. However, it can also be compiled into an exportable object using an unofficial compiler.

An example of a Python program

In the following source code I wrote a simple program.

In the first line, I assign the value "Italy" to the variable (country).

country = "Italy"
print (country)

In the second line I use the PRINT statement to display the value of the variable.

The Python interpreter processes the instructions in sequence and displays the string on the screen.

Italy

It is a deliberately simple example.

Now it should be clearer what it consists of and how the Python language works.

Why is Python an interactive language?

The Python language is interactive because it can also be programmed from the command line.

A practical example

I assign a value to a variable A through the command line.

assignment of the value 10 to the variable A

Then I write the PRINT statement to display the value of variable A on the command line.

Python shows me the value I previously assigned to the variable.

Python displays the value assigned to the variable

I did everything from the command prompt and without creating a source code.

For this reason Python is called interactive.

What does object-oriented programming mean?

The Python language is object-oriented because it allows you to associate properties and attributes to individual objects.

A practical example

I create the "mammal" class.

Then I assign the "gender" property to the class and assign the "animal" value to it.

python example class

Now I create an instance to associate the Panda object with the Mammal class.

python class example

If I ask Python to display the "gender" property of the Panda object, the interpreter displays "animal" in output.

why Python is an object oriented programming

The object (Panda) automatically inherited all properties of the class (Mammal).

How to install Python on your PC

To start programming with the Python language, you need to install the interpreter software.

Where to find the Python interpreter?

It can be downloaded for free from the official language site ( www.python.org ) and installed on your computer.

Python home page

The Python interpreter is available for all popular operating system platforms (Microsoft Windows, Linux, Mac OS).

The Python interpreter software includes:

  • a code editor
  • an interpreter for executing or analyzing programming bugs during development and development.
  • a command line ( shell )

 


 

Segnalami un errore, un refuso o un suggerimento per migliorare gli appunti

FacebookTwitterLinkedinLinkedin
knowledge base

Python