Skip to main content

Posts

Showing posts with the label Sequence

Sequence

Sequence In Python, sequence is the generic term for an ordered set. There are several types of sequences in Python, the following three are the most important. Lists are the most versatile sequence type. The elements of a list can be any object, and lists are mutable - they can be changed. Elements can be reassigned or removed, and new elements can be inserted. Tuples are like lists, but they are immutable - they can't be changed. Strings are a special type of sequence that can only store characters, and they have a special notation. However, all of the sequence operations described below can also be used on strings. Sequence Operations + combines two sequences in a process called concatenation. For example, [1,2,3]+[4,5] will evaluate to [1,2,3,4,5]. * repeats a sequence a (positive integral) number of times. For example, [1,11]*3 will evaluate to [1,11,1,11,1,11]. x in mySeq will return True if x is an element of mySeq, and False otherwise. You can negate thi...