CSC111 Exercises on lists of lists

From dftwiki3
Jump to: navigation, search

--D. Thiebaut (talk) 09:39, 28 March 2014 (EDT)


Exercises on Lists of Lists


L1 =[
        ( "Film", "Release year", "1998 rank", "2007 rank", "Change" ),
        (  "Citizen Kane",      1941, (1, 1), ("Steady",   0)  ),
        (  "Casablanca",	       1942, (2, 3), ("Decrease", 1)  ),
        (  "The Godfather",     1972, (3, 2), ("Increase", 1 ) ),
        (  "Gone with the Wind",1939, (4, 6), ("Decrease", 2 ) ),
        (  "Lawrence of Arabia",1962, (5, 7), ("Decrease", 2 ) ),
        (  "The Wizard of Oz",  1939, (6, 10),("Decrease", 4 ) ),
        (  "The Graduate",      1967, (7, 17),("Decrease", 10) ) 
      ]


Write some Python code that will answer the following questions

Question 1
What is the name of the movie ranked 4th in 1998? Assume the list is sorted by 1998 rank.
Question 2
What is the year in which Casablanca was released?
Question 3
Print only the 2007 ranking of all the movies, one above the other.