Name | print() |
||
---|---|---|---|
Examples |
i = 123 f = 45.6 s = "this is a string" list_of_stuff = ["foo", "bar", "baz"] print(i) print(f) print(s) print(list_of_stuff) | ||
Description |
The print() function writes to the console area, the black rectangle at the bottom of the Processing environment. This function is often helpful for looking at the data a program is producing. Using print() on an object will output a string representation of that object, as determined by its internal __str__ and __repr__ methods (more information here). In Python Mode, print() and println() are functionally identical. Under the hood, print in Python 2 is not actually a function at all--it is a statement, and can be used without quotes: print i. Writing print(i) is print plus the single-element expression (i). When we write print(1,2), the statement outputs a tuple: (1, 2). To change this behavior, make the first line of a sketch: from __future__ import print_function. This turns print(i) into a function, disallows print i, and causes print(1, 2) to output 1, 2 rather than (1, 2). |
||
Syntax | print(what) | ||
Parameters |
| ||
Related |
print() |
Updated on Tue Feb 27 14:07:12 2024.
If you see any errors or have comments, please let us know.
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License