Python datatype

One thing has fascinated me since ancient times. In languages ​​like c, we need to declare data types, e.g. integer as int, character as char, etc. I mean we pass the data type information to the C compiler. But in python, let's say I declare

c = 2 

The compiler then interprets c as a whole. And if I announce

 c = "a" 

the compiler interprets c as a character. My doubt is how the compiler knows how to assign the appropriate data type to c without explicitly declaring it. This may be a major question for python experts, but shed light on this

+4
source share
1 answer

Python is a dynamically typed language .

The compiler does not interpret type information when compiling python code. These are all just objects with methods, and it depends on your own code to use the values ​​that it likes.

+6
source

All Articles