CSC111 Exercises on Strings and Lists Indexes
--D. Thiebaut 09:24, 13 October 2011 (EDT)
The best reference: docs.python.org
Exercise 1
names = [ "Alice", "FRANK", "Lou", "maria", "JoSH" ]
- Print the names above in lowercase, with the first letter uppercase
- Center the names, one above the other, in a box of 40 characters
Exercise 2
- Given the following declaration
text = """A Tale of Two Cities | Charles Dickens | Historical fiction | English | 1859 | 200 million[1] The Lord of the Rings | J. R. R. Tolkien |High fantasy | English |1954–1955 |150 million[2] The Hobbit | J. R. R. Tolkien | Juvenile fantasy | English | 1937 | 100 million[3] Dream of the Red Chamber | Cao Xueqin | Historical fiction | Chinese | 1759-1791 | 100 million [4] And Then There Were None | Agatha Christie | Mystery | English | 1939 | 100 million[5]"""
- Write some code that will print out only the titles of the book, one above the other
- Write some more code that will print out the author followed by a colon, followed by the title
- Still some more code to display the title of the book and the number of books sold (last field on each line)