Python is a programming language known for its simple, readable syntax. It is the most used language in data science and artificial intelligence, but it serves much more.

How it works

Python code is executed by an interpreter that reads the file and runs line by line. You do not need to compile first. This makes the write, run and fix cycle very fast.

The language uses indentation to organize blocks, which keeps code visually clean. To run a file:

Terminal
python3 script.py

Python also has pip, a package manager that installs libraries built by the community:

Terminal
pip install requests

Libraries are one of the main reasons for the language's success. For AI, there are options for machine learning, data analysis and integration with models.

Practical example

Imagine you have a sales spreadsheet and want the total per product. With a few lines of Python, you can read the file, sum the values and print the result.

Python · vendas.py
vendas = [
    {"produto": "camiseta", "valor": 50},
    {"produto": "boné", "valor": 30},
    {"produto": "camiseta", "valor": 50},
]

totais = {}
for v in vendas:
    totais[v["produto"]] = totais.get(v["produto"], 0) + v["valor"]

print(totais)

The result shows t-shirt with 100 and cap with 30. The same reasoning, with libraries, scales to much larger analyses.

What it's used for

Python is used in:

  • Data science and analysis.
  • Machine learning and AI, including the use of language models via API.
  • Automation of tasks and everyday scripts.
  • Web scraping, bots and website back end.

For those who are starting out, it is one of the most welcoming languages. For those who work with code agents, it is usually a common choice, because models know the language well and generate Python code easily.

Caveats

Python is not the fastest option in raw execution. In projects that require a lot of performance, some work can be done in other languages. It is also worth using virtual environments to keep each project's dependencies separate.

Difference between Python and JavaScript

Python is widely used for data, AI and automation. JavaScript dominates the browser and, with Node.js, also runs on servers. Many projects use both: Python for data and models, JavaScript for the interface.