presnick / RunestoneServer

Interactive books for computer science
http://interactivepython.org
Other
26 stars 46 forks source link

In functions2.rst, explain difference between return and print #31

Closed presnick closed 9 years ago

presnick commented 10 years ago

When an expression evaluates to a value, including when a function returns a value, there are three things that might happen to the value: -- show it to the user (print) -- use it as part of a more complex expression -- save it for later use, either by assigning to a variable, or adding to a data structure like a list or a dictionary.

Print just shows things to the user. Return makes it available for one of the other two uses.

aerenchyma commented 9 years ago

IIRC this is all set, though if we want to add other textbook things those could be issues too. Can open again if you think I'm incorrect here of course