tailieunhanh - Ebook Starting out with python (3rd edition): Part 2

(BQ) Part 2 book "Starting out with python" has contents: Lists and tuples, more about strings, dictionaries and sets, classes and object oriented programming, inheritance, recursion, GUI programming. | Page 308 29/07/14 8:12 AM user 308 /203/PH01490_GE/9781292065502_GADDIS/GADDIS_STARTING_OUT_WITH_PYTHON_GLOBAL_EDITI . Chapter 6   Files and Exceptions 10. Golf Scores The Springfork Amateur Golf Club has a tournament every weekend. The club president has asked you to write two programs: 1. A program that will read each player’s name and golf score as keyboard input, and then save these as records in a file named . (Each record will have a field for the player’s name and a field for the player’s score.) 2. A program that reads the records from the file and displays them. CHAPTER Page 309 29/07/14 8:16 AM user 7 /203/PH01490_GE/9781292065502_GADDIS/GADDIS_STARTING_OUT_WITH_PYTHON_GLOBAL_EDITI . Lists and Tuples Topics Sequences Introduction to Lists List Slicing Finding Items in Lists with the in Operator List Methods and Useful Built-in Functions Copying Lists Processing Lists Two-Dimensional Lists Tuples Sequences Concept: A sequence is an object that holds multiple items of data, stored one after the other. You can perform operations on a sequence to examine and manipulate the items stored in it. A sequence is an object that contains multiple items of data. The items that are in a sequence are stored one after the other. Python provides various ways to perform operations on the items that are stored in a sequence. There are several different types of sequence objects in Python. In this chapter we will look at two of the fundamental sequence types: lists and tuples. Both lists and tuples are sequences that can hold various types of data. The difference between lists and tuples is simple: a list is mutable, which means that a program can change its contents, but a tuple is immutable, which means that once it is created, its contents cannot be changed. We will explore some of the operations that you may .