I am a complete newbie to python transiting from C++. 
While learning C++, I was explained that header files tells about the working of the function or define them to the compiler so that it understands what means what i.e., iostream contains the definition of cin (nd much more) so that the compiler knows that it is a keyword and understands its function.
However, python and java do not need header files.
 So basically how does the compiler understands the actual meaning/function of 'print' or 'input' in python?????
Header files in C/C++ are a "copy paste" mechanism. The included header file is literally written into the file while preprocessing (copy pasting the source code together).
After that is done,  the compiler transaltes the source code. The linker then connects the function calls.
That is somewhat outdated and error prone -> can be really frustrating as well when sth doesnt work as expected.
Newer languages have module systems, which are nicer (import simply does it).
Why Python and java does not need any header file whereas C and C++ needs them