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)
 2
 >>>​​ ​​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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.