Sec chat between couples
The block of code that does a task for us is called a , just to make clear that what we are talking about is a function rather than some other kind of Python expression.
Functions are an important concept in programming, and we only mention them at the outset to give newcomers a sense of the power and creativity of programming.
Later we'll see how to use functions when tabulating data, as in 1.1.
Test your understanding by modifying the examples, and trying the exercises at the end of the chapter.
Let's begin by finding out the length of a text from start to finish, in terms of the words and punctuation symbols that appear. But there are only four distinct vocabulary items in this phrase.
How many distinct words does the book of Genesis contain?
To work this out in Python, we have to pose the question slightly differently.