CS 1301 Chapter Notes - Chapter 8: Substring, Short Circuit, Empty String
Document Summary
Compound data types- types that comprise smaller pieces; made of components, or elements that are themselves values. Upper- method that can be invoked on any string object to create a new string where all characters are in uppercase: lower, capitalize, swapcase. 8. 3 working with the parts of a string. Indexing operator- python uses square brackets to enclose index; selects single character substring from a string. Len- returns number of characters in string: ex. len ( happy ) 5. Negative indices- count backward from end of string: ex. fruit[-1] gives last letter; fruit[-2] gives second to last letter. Traversal- pattern of processing; to iterate through elements of a collection, performing a similar operation on each. Slice- able to obtain substring through this method; slice a list to refer to some sublist of items in the list; part of a string (substring) specified by range of indices. Use (= =) in order to draw comparisons between two strings.