Abstract
The real power of computers is in their ability to execute repetitive tasks without complaint. A CPU is perfectly happy chugging along flipping bits until it burns out. A calculator will keep calculating for as long as you give it numbers to work with. And sure—keep mashing F5 on your favorite web site that is currently having server trouble—your router won't care.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
It is a convention to use variable i in loops that have a counter; this is one of the few exceptions where it is okay to not use a descriptive variable name!
- 2.
You can actually store a really huge number of items in a tuple, but if you need more than a few variables, you should rethink your choice to use a tuple.
- 3.
The object is called an iterator if you want to research more. The range() function also returns an iterator.
- 4.
Just like using i is a convention, j is a convention in a nested loop. If you really need them, k and l are next.
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 2018 Phillip Johnson
About this chapter
Cite this chapter
Johnson, P. (2018). Loops. In: Make Your Own Python Text Adventure. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-3231-6_7
Download citation
DOI: https://doi.org/10.1007/978-1-4842-3231-6_7
Published:
Publisher Name: Apress, Berkeley, CA
Print ISBN: 978-1-4842-3230-9
Online ISBN: 978-1-4842-3231-6
eBook Packages: Professional and Applied ComputingApress Access BooksProfessional and Applied Computing (R0)