Python 3


PAGE 1/4
Data types
Home >>> Free online lessons

Python is dynamic!

One of the benefits of using the Python 3 language is that any variable can remember dynamically, during a program, values of different types, without imposing the type on the declaration, such as initialization in C ++.

The following code is already executed:
Editor -
Console / result done
What do we notice? Initially, the variable n retained the numeric value 123, then a string, "Python", and at the end, again a numeric value, this time real one, 23.25. After each assignment, we displayed what the variable n holds.

Even the colors in the Python editor are changed because data differs as type ... 🧐

We also identified our first problem when we wanted to add two numbers entered from the keyboard. By default, the input function takes the information entered and provides it as a string for manipulation in our code, but 2 + 3 do not make 23!

Let's study these data types more!
Advance to the next page of the lesson.
 home   list  LESSONS   arrow_upward