Simple Python Exercises¶
http://ideone.com/ can be used to write the code.
Create a sorted list from the following list of 2-tuples by the second element of each tuple. The original list should be left intact. (5 minutes)
indata = [ ('a', 0), ('b', 2), ('c', 1), ]
Count the number of unique values in a list. (3 minutes)
import random indata = [random.randrange(100) for it in xrange(20)]
Clean up Python comments from a source file. (10 minutes)