Using the features of the print() function
In many cases, the print()
function is the first function we learn about. The first script is often a variation on the following:
>>> print("Hello, world.")
Hello, world.
The print()
function can display multiple values, with helpful spaces between items.
When we write this:
>>> count = 9973
>>> print("Final count", count)
Final count 9973
We see that a space separator is included for us. Additionally, a line break, usually represented by the \n
character, is printed after the values provided in the function.
Can we control this formatting? Can we change the extra characters that are supplied?
It turns out that there are some more things we can do with print()
.
Getting ready
Consider this spreadsheet, used to record fuel consumption on a large sailboat. It has rows that look like this: