Python Programming for the Absolute Beginner, 3rd Edition
Overview
You've seen how variables are a great way to access information, but as your programs grow in size and complexity, so can the number of your variables. Keeping track of all of them can become a lot of work. Therefore, in this chapter, you'll learn about the idea of sequences and meet a new type, called the tuple, which let's you organize and manipulate information in ordered groups. You'll also see how a type you've already encountered, the string, is really a sequence too. You'll also learn about a new kind of loop that's built just for working with sequences. Specifically, you'll learn how to do the following:
-
Construct for loops to move through a sequence
-
Use the range() function to create a sequence of numbers
-
Treat strings as sequences
-
Use tuples to harness the power of sequences
-
Use sequence functions and operators
-
Index and slice sequences
Категории