Skip to Content
Python Workout
book

Python Workout

by Reuven M. Lerner
July 2020
Beginner to intermediate
248 pages
6h 58m
English
Manning Publications
Content preview from Python Workout

6 Functions

Functions are one of the cornerstones of programming--but not because there’s a technical need for them. We could program without functions, if we really had to. But functions provide a number of great benefits.

First, they allow us to avoid repetition in our code. Many programs have instructions that are repeated: asking a user to log in, reading data from a particular type of configuration file, or calculating the length of an MP3, for example. While the computer won’t mind (or even complain) if the same code appears in multiple places, we--and the people who have to maintain the code after we’re done with it--will suffer and likely complain. Such repetition is hard to remember and keep track of. Moreover, you’ll likely find that ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python for Programmers

Python for Programmers

Paul Deitel, Harvey Deitel
Python One-Liners

Python One-Liners

Christian Mayer

Publisher Resources

ISBN: 9781617295508Supplemental ContentPublisher SupportOtherPublisher WebsiteSupplemental ContentErrata PagePurchase Link