June 2015
Intermediate to advanced
298 pages
7h 15m
English
When working with Python's REPL, we can enter an expression and Python prints the result. In other contexts, we must use the print() function to see results. The print() function implicitly writes to sys.stdout, so the results will be visible on the console where we ran the Python script.
We can provide any number of expressions to the print() function. Each value is converted to a string using the repr() function. The strings are combined with a default separator of ' ' and printed with a default line ending of '\n'. We can change the separator and line ending characters. Here are some examples of this:
>>> print("value", 355/113) value 3.1415929203539825 >>> print("value", 355/113, sep='=') value=3.1415929203539825 >>> print("value", ...Read now
Unlock full access