Monday, August 10, 2009

Python Sequences

I just viewed some videos on Python sequences and lists at adaptivelearningonline.net . My notes follow:

  • A populated tuple need not be enclosed in parameters. Does that mean that
the print method in
print "Hello", "Again"

takes a tuple of Strings?
  • Even though ['h','e','l','l','o'] and "Hello" are both sequences, we cannot concatenate them, because we cannot concatenate the non list with a list.
  • Sequences can be multiples... "Hello"*3 will result in "HelloHelloHello"
  • Lists support a sort method. This method will take a list of objects and sort the list. This method does not return anything.
  • Python has a sorted() function which takes a String and sorts it. It returns a new string which is the sorted string.

No comments: