I expected the output to be some kind of error but instead both the languages handle it differently. Please explain why this happens and is the print function capable of doing something else other than just displaying?

You could check the references to see what each function is doing: print, printf. It's also unclear why you'd expect those two very different functions from two distinct languages return the same thing.
– AyxanJul 21 at 5:58

3

Comparing two functions with similar names of two different programming language makes no sense.
– SpikatrixJul 21 at 6:08

The built-in print function in Python is implemented in C, however, unlike C version it does not return the number of characters it wrote on the output object. To check, what it is returning, look at the source code. From Python's source code Git repository: