sequences are compared using the operators ===and !when comparing two sequencesthe first elements of each sequence are compared if they differthis determines the result if they're the samethe comparison moves to the second element of each sequence this process continues until two different elements are found or no more elements exist in either of the sequences if the end of both sequences is reachedthe sequences are considered equal if is subsequence of bthen strings are compared using lexicographical ordering each character is assigned unique numerical index determined by the character set (such as ascii or unicodea character is less than another character if its index is less one caution concerning character ordering is that the preceding simple comparison operators are not related to the character ordering rules associated with locale or language settings thusyou would not use these operations to order strings according to the standard conventions of foreign language (see the unicodedata and locale modules for more informationanother cautionthis time involving strings python has two types of string databyte strings and unicode strings byte strings differ from their unicode counterpart in that they are usually assumed to be encodedwhereas unicode strings represent raw unencoded character values because of thisyou should never mix byte strings and unicode together in expressions or comparisons (such as using to concatenate byte string and unicode string or using =to compare mixed stringsin python mixing string types results in typeerror exceptionbut python attempts to perform an implicit promotion of byte strings to unicode this aspect of python is widely considered to be design mistake and is often source of unanticipated exceptions and inexplicable program behavior soto keep your head from explodingdon' mix string types in sequence operations string formatting the modulo operator ( dproduces formatted stringgiven format stringsand collection of objects in tuple or mapping object (dictionaryd the behavior of this operator is similar to the sprintf(function the format string contains two types of objectsordinary characters (which are left unmodifiedand conversion specifierseach of which is replaced with formatted string representing an element of the associated tuple or mapping if is tuplethe number of conversion specifiers must exactly match the number of objects in if is mappingeach conversion specifier must be associated with valid key name in the mapping (using parenthesesas described shortlyeach conversion specifier starts with the character and ends with one of the conversion characters shown in table table string formatting conversions character output format , decimal integer or long integer unsigned integer or long integer octal integer or long integer hexadecimal integer or long integer hexadecimal integer (uppercase lettersfloating point as [-] dddddd floating point as [-] dddddde+-xx lib fl ff