Those extra '1's at the end of each number are the return value from printf, which returns the number of chars that it prints. The return value of a function called in the interactive interpreter is automatically printed (unless it’s None).
In fact, the interactive interpreter prints any non-None expression that isn’t assigned. And of course it adds a newline to those expressions, which explains why the output in your first code block is on separate lines.
Your pr function doesn’t have a return statement, so it returns None, and thus no extra stuff gets printed.