Printing Information

In Writing and Running a Program, built-in function print was used to print values to the screen. We will use print to print messages to the users of our program. Those messages may include the values that expressions produce and the values that the variables refer to. Here are two examples of printing:

 >>>​​ ​​print(1​​ ​​+​​ ​​1)
 >>>​​ ​​print(​​"The Latin 'Oryctolagus cuniculus' means 'domestic rabbit'."​​)
 The Latin 'Oryctolagus cuniculus' means 'domestic rabbit'.

Function print doesn’t allow any styling of the output: no colors, no italics, no boldface. All output is plain text.

The first function call does what you would expect from the numeric examples we have seen previously, but the second does something ...

Get Practical Programming, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.