As you said in a comment:
Setting
:resultstovalueswould only print the last value of the function. My goal is to have exactly the same output as in the interactive interpreter: the values of all typed expressions and of all print statements.
You can't have both, but if you want "exactly the same output as in an interactive interpreter" from multiple lines, you can get that by printing the results of the expression from the repr function if the value is not None.
So here's a convenience function for that, output (indented because I edited it in a separate python-mode buffer, accessed with C-c '):
#+BEGIN_SRC python :session :results output def output(obj): if obj is None: return None print(repr(obj)) import sys print(sys.version) output(sys.version) output("hello") output(4-1) output(list("hello")) #+END_SRC #+RESULTS: : 3.6.4 |Anaconda custom (64-bit)| (default, Mar 13 2018, 01:15:57) : [GCC 7.2.0] : '3.6.4 |Anaconda custom (64-bit)| (default, Mar 13 2018, 01:15:57) \n[GCC 7.2.0]' : 'hello' : 3 : ['h', 'e', 'l', 'l', 'o'] : : Note that strings will have their quotes and literal newlines, while numbers will also look like their literals. This is how the interactive interpreter works.
But I don't think it's very elegant in this context, and as people have been writing Python in Emacs for a long time, I doubt we can come up with a better approach.
Explanation
In a code block with :results output it takes the output from standard out, that is, what you print, as the results. This is what you were doing: