The print function first converts the object to a string (if it is not already a string). The print function will also put a space before the object if it is not the start of a line and a newline character at the end.
When you use stdout, that time you need to convert the object to a string by yourself and you will do it by calling "str", and there is no newline character.
So the below-written print() statement is equivalent to what we have done using sys.stdout():-
sys.stdout.write(str(10) + '\n')