Published on
· July 10, 2026

What is Python? A beginner's guide with examples

Blog
  • Photo of Henrico Piubello
    Henrico Piubello
    Henrico Piubello
    IT Specialist - Grupo Voitto

    IT Specialist - Grupo Voitto

a snake representing the logo of the Python programming language

Python is a high-level, interpreted and multiparadigm programming language, created by Guido van Rossum in 1991. It is used for data science, artificial intelligence, automation and web development, and stands out for its simple and readable syntax, which makes it ideal for beginners.

What is Python?

Python is a high-level, interpreted and object-oriented programming language, designed to make code clean, simple and highly readable. Released in the early 1990s by the Dutch programmer and mathematician Guido van Rossum, it became one of the most influential languages in the world.

Python prioritizes developer productivity. Its dynamic and strong typing ensures flexibility without giving up safety, and variables do not need to be declared with a fixed type. The language supports multiple paradigms, including object orientation, functional and imperative programming, adapting to the shape of each project.

The language's philosophy is summed up in PEP 20, Tim Peters' "Zen of Python", which states: "Readability counts". This principle of valuing readable code over convoluted tricks is what sustains Python's popularity among beginners and experienced engineering teams alike.

Fun fact: contrary to what many think, the name Python does not come from the python snake, but from the British comedy group Monty Python, from the 1970s — a touch of humor from the language's creators.

How does Python work?

Python works through an interpreter that reads and runs the code line by line. This means there is no need to compile the code before running it, which makes the development cycle more agile and the feedback almost immediate.

Python has a vast standard library that offers ready-to-use features, such as file handling, internet access and data processing. These libraries reduce the amount of code the developer needs to write from scratch and speed up the implementation of common tasks.

Python's object-oriented nature allows programs to be organized into classes and objects, resulting in a modular and reusable structure. Combined with an active community and an abundance of tutorials and third-party packages, this architecture makes Python a practical choice for both small scripts and large systems.

Python is today the most used programming language in the world, driven by data science and artificial intelligence. In the TIOBE index of July 2026, Python leads comfortably ahead of C, C++ and Java, a position it has held consistently for years.

The adoption pace is significant. In the Stack Overflow Developer Survey 2025, 57.9% of developers reported having used Python in the last year — a jump of about 7 percentage points compared to 2024 — and Python figures as the language that most professionals want to learn next.

This dominance has historical roots: in 2025, Python reached about 26% share in TIOBE, the highest mark ever recorded by any language in the index's history. The engine behind this growth is AI (Artificial Intelligence), since most machine learning frameworks, such as TensorFlow and PyTorch, have Python as their main interface. If you want to understand the full landscape, it is worth knowing the most used programming languages in the world.

What is the difference between Python 2 and Python 3?

The central difference is that Python 3 is the current and recommended version, while Python 2 was officially discontinued in 2020 and no longer receives security updates. Every new project should be born in Python 3. The table below summarizes the points that matter most for beginners.

AspectPython 2Python 3
StatusDiscontinued (2020)Current and maintained version
Print syntaxprint "texto"print("texto")
Unicode supportLimitedNative by default
Integer divisionTruncates the resultReturns a real number
PerformanceLess optimizedFaster interpreter

The change in the print function's syntax illustrates the evolution well. In Python 2, it was a statement:

print "Olá, mundo!"

In Python 3, it became a function with parentheses, more consistent with the rest of the language:

print("Olá, mundo!")

Beyond syntax, Python 3 improved support for characters from different languages through native Unicode, optimized interpreter execution and improved memory management, resulting in faster and more efficient programs.

How to install Python?

Installing Python takes a few minutes and is the first step to writing your programs. The process works similarly on Windows, macOS and Linux; if you have doubts about your environment, see the comparative analysis between operating systems. Follow the steps below:

  1. Go to the official Python website and download the version suited to your operating system (Windows, macOS or Linux).
  2. Start the installer and, on Windows, check the "Add Python to PATH" option — it lets you run Python straight from the terminal.
  3. Verify the installation by opening the terminal and typing the command below, which should display the installed version.
python --version
  1. Write your first program in an IDE (Integrated Development Environment) like Visual Studio Code or PyCharm; if you want to go deeper, see what an IDE in the glossary is.
print("Hello World")
  1. Save the file as hello.py, navigate to the folder in the terminal with the cd command and run the program.
python hello.py

When you see the Hello World output in the terminal, congratulations: you have just run your first Python program and are ready to move on to the language's concepts.

What are the data types in Python?

Python offers a set of built-in data types that cover most everyday needs. The five fundamental ones for beginners are numbers, strings, lists, tuples and dictionaries — each with a specific purpose in modeling information.

Numbers include integers (int), floating point (float) and complex (complex):

numero_inteiro = 42  # inteiro
numero_flutuante = 3.14
numero_complexo = 2 + 3j

Strings are sequences of characters, defined with single or double quotes:

nome = 'Alice'
mensagem = "Olá, mundo!"

Lists are ordered and mutable sequences, defined with square brackets:

lista_numeros = [1, 2, 3, 4, 5]
lista_misturada = [1, 'dois', 3.0, True]

Tuples are similar to lists, but immutable, defined with parentheses:

tupla_numeros = (1, 2, 3, 4, 5)
tupla_misturada = (1, 'dois', 3.0, True)

Dictionaries map keys to values and are defined with braces:

dicionario = {'nome': 'Alice', 'idade': 30, 'cidade': 'São Paulo'}

Practice challenge: create variables for your age (int), name (str), height (float) and whether you have pets (bool). Then print the type of each one using the type() function and compare the output with what you expected.

What operators does Python offer?

Python provides operators to manipulate data in different ways. The three groups most used by beginners are arithmetic, comparison and logical, each returning a specific result from the supplied values.

Arithmetic operators perform mathematical operations:

a = 10
b = 3
soma = a + b
subtracao = a - b
multiplicacao = a * b
divisao = a / b
resto = a % b

Comparison operators compare values and return True or False:

a = 10
b = 3
igual = a == b
diferente = a != b
maior = a > b
menor = a < b

Logical operators combine boolean values:

a = 10
b = 3
c = 5
e = a > b and b < c
ou = a > b or b > c
nao = not (a > b)

Practice challenge: create two numeric variables and print the result of the sum, subtraction, multiplication, division (handling division by zero), remainder and power between them, using the +, -, *, /, % and ** operators.

How do control flow structures work?

Control flow structures allow code blocks to be executed based on conditions or repetitions. In Python, the three most common are if-else, the for loop and the while loop, and all depend on indentation to delimit their blocks.

The if-else executes one block when the condition is true and another when it is false:

idade = 18
if idade >= 18:
    print('Você é maior de idade.')
else:
    print('Você é menor de idade.')

The for loop iterates over the elements of a sequence, such as a list or dictionary:

numeros = [1, 2, 3, 4, 5]
for numero in numeros:
    print(numero)

The while loop repeats a block as long as the condition remains true:

contador = 0
while contador < 10:
    print(contador)
    contador += 1

Mastering these structures requires logical reasoning before syntax. If you feel the concepts are still loose, it is worth reinforcing the foundation with a programming logic guide before moving on to more complex problems.

How to create functions in Python?

Functions are reusable code blocks that perform a specific task. In Python, you define a function with the def keyword, followed by the name, the parameters in parentheses and an indented block with the instructions to execute. They make the code more modular and easier to maintain.

The example below creates a function that sums two numbers and returns the result:

def soma(a, b):
    resultado = a + b
    return resultado

resultado_soma = soma(5, 3)
print(resultado_soma)  # Output: 8

Functions also accept parameters with default values, used when no argument is supplied in the call:

def saudacao(nome="Usuário"):
    print(f"Olá, {nome}!")

saudacao()  # Output: Olá, Usuário!
saudacao("Renata")  # Output: Olá, Renata!

A Python function can also return multiple values at once using tuples:

def divisao_e_resto(a, b):
    quociente = a // b
    resto = a % b
    return quociente, resto

resultado_divisao, resultado_resto = divisao_e_resto(10, 3)
print(resultado_divisao)  # Output: 3
print(resultado_resto)  # Output: 1

Practice challenge: create a calcular_media function that takes a list of numbers and returns their average, using sum() to add and len() to count the elements. Then call the function with a list of your choice and print the result.

Where to practice Python with code examples?

The best way to practice Python is to build small projects that solve real problems, applying theoretical concepts in practice. Creating programs from scratch consolidates learning much more than just reading tutorials.

Good ideas to start include a BMI (Body Mass Index) calculator, a number guessing game or a to-do list app. Each project forces you to combine variables, conditions, loops and functions in a concrete context. A useful collection is the 25 Python projects for beginners from freeCodeCamp.

Communities and challenge platforms also help you evolve with gradual problems. At CodeCrush, you find content that deepens areas where Python shines, such as creating machine learning projects. The secret is consistency: set aside a fixed time per week to program and review your own code.

Conclusion

If you are starting in programming in 2026, learning Python is one of the safest bets you can make. The language combines a smooth learning curve with a very high ceiling: the same Python that runs your first Hello World sustains data pipelines and artificial intelligence models in production at the world's largest companies. Start with the fundamentals in this guide — data types, operators, control structures and functions — and turn each concept into a small project. Fluency comes from constant practice, not accumulated theory.

## faq

Frequently asked questions

What is Python for?

Python is used for data science, artificial intelligence, task automation, web development and infrastructure scripting. Its vast standard library and package ecosystem like NumPy, Pandas and Django make the language productive both in rapid prototypes and in large-scale enterprise systems.

Is Python hard to learn?

No. Python is considered one of the easiest languages to learn because of its clean, English-like syntax and the absence of low-level details like manual memory management. Beginners can write useful programs in the first weeks, which makes it the preferred gateway into programming.

What is the difference between Python 2 and Python 3?

Python 3 is the current and recommended version; Python 2 was discontinued in 2020. Python 3 brought native Unicode support, the print() function with parentheses, real division by default and better performance. Every new project should use Python 3, since Python 2 no longer receives security updates.

Is it worth learning Python in 2026?

Yes. Python leads the TIOBE index and is the most desired language in the Stack Overflow survey, driven by the explosion of artificial intelligence and data science. Demand for Python developers remains high in automation, back-end and machine learning, with competitive salaries in the Brazilian market.

Do I need to know math to learn Python?

Not to start. The foundation of Python is programming logic: variables, conditions and loops, which require reasoning, not advanced calculus. Math only becomes relevant in specific areas such as data science and machine learning. For automation and web development, basic high-school knowledge is enough.

## continue lendo

Keep browsing

About the author

Photo of Henrico Piubello

Henrico Piubello

IT Specialist - Grupo Voitto · Grupo Voitto

See profile and all articles