It sounds like you are referring to syntax highlighting, which means, in the case of python code, when opening a file with python code in a terminal, the various key words and variables are colored consistently throughout the file. If one opens a file of python code in nano, e.g.
nano some_file_of_python_code.py, then it's usually colored by default.
In the vim editor, one can configure syntax highlighting with the configuration: syntax on, in the vim configuration file in
/home/$USER/.vimrc file.
Both nano and vim can highlight the syntax of numerous programming languages. Here's an example of nano using color for a file of python code:
View attachment 32543
Here is an example of vim using syntax highlighting on the same file:
View attachment 32544
The actual colors used for highlighting can themselves be configured in the configuration files if one prefers to use non-default colors.