Strings are the simplest and easy to use in Python.rnString pythons are immutable.rnWe can simply create Python String by enclosing a text in single as well as double quotes. Python treat both single and double quotes statements same.rnAccessing Strings:
• In Python, Strings are stored as individual characters in a contiguous memory location.
• The benefit of using String is that it can be accessed from both the directions in forward and backward.
• Both forward as well as backward indexing are provided using Strings in Python. rno Forward indexing starts with 0,1,2,3,....rno Backward indexing starts with -1,-2,-3,-4,....rnStrings OperatorsrnThere are basically 3 types of Operators supported by String:rn1. Basic Operators.rn2. Membership Operators.rn3. Relational Operators.rnBasic Operators:rnThere are two types of basic operators in String. They are "+" and "*".rnString Concatenation Operator :(+)rnThe concatenation operator (+) concatenate two Strings and forms a new String.rnReplication Operator: (*)rnReplication operator uses two parameter for operation. One is the integer value and the other one is the String.rnThe Replication operator is used to repeat a string number of times. The string will be repeated the number of times which is given by the integer value.rnMembership OperatorsrnMembership Operators are already discussed in the Operators section. Let see with context of String.rnThere are two types of Membership operators:rn1) in:"in" operator return true if a character or the entire substring is present in the specified string, otherwise false.rn2) not in:"not in" operator return true if a character or entire substring does not exist in the specified string, otherwise false.rnRelational Operators:rnAll the comparison operators i.e., (<,><=,>=,==,!=,<>) are also applicable to strings. The Strings are compared based on the ASCII value or Unicode(i.e., dictionary Order).rnSlice Notation:rnString slice can be defined as substring which is the part of string. Therefore further substring can be obtained from a string.rnThere can be many forms to slice a string. As string can be accessed or indexed from both the direction and hence string can also be sliced from both the direction that is left and right. rnString Functions and Methods:rnThere are many predefined or built in functions in String. They are as follows:rncapitalize() It capitalizes the first character of the String.rncount(string,begin,end) Counts number of times substring occurs in a String between begin and end index.rnendswith(suffix ,begin=0,end=n) Returns a Boolean value if the string terminates with given suffix between begin and end.rnfind(substring ,beginIndex, endIndex) It returns the index value of the string where substring is found between begin index and end index. rnindex(subsring, beginIndex, endIndex) Same as find() except it raises an exception if string is not found.rnisalnum() It returns True if characters in the string are alphanumeric i.e., alphabets or numbers and there is at least 1 character. Otherwise it returns False.rnisalpha() It returns True when all the characters are alphabets and there is at least one character, otherwise False.rnisdigit() It returns True if all the characters are digit and there is at least one character, otherwise False.rnislower() It returns True if the characters of a string are in lower case, otherwise False.rnisupper() It returns False if characters of a string are in Upper case, otherwise False.rnisspace() It returns True if the characters of a string are whitespace, otherwise false.rnlen(string) len() returns the length of a string.rnlower() Converts all the characters of a string to Lower case.rnupper() Converts all the characters of a string to Upper Case.rnstartswith(str ,begin=0,end=n) Returns a Boolean value if the string starts with given str between begin and end.rnswapcase() Inverts case of all characters in a string.rnlstrip() Remove all leading whitespace of a string. It can also be used to remove particular character from leading.rnrstrip() Remove all trailing whitespace of a string. It can also be used to remove particular character from trailing.rnPython Listrn1).Python lists are the data structure that is capable of holding different type of data.rn2).Python lists are mutable i.e., Python will not create a new list if we modify an element in the list.rn3).It is a container that holds other objects in a given order. Different operation like insertion and deletion can be performed on lists.rn4).A list can be composed by storing a sequence of different type of values separated by commas.rn5).A python list is enclosed between square([]) brackets.rn6).The elements are stored in the index basis with starting index as 0.rnList Operations:rnVarious Operations can be performed on List. Operations performed on List are given as:rna) Adding Lists:rnLists can be added by using the concatenation operator(+) to join two lists.rnFunctions and Methods of Lists:rnThere are many Built-in functions and methods for Lists. They are as follows:rnThere are following List functions:rnFunction Descriptionrnmin(list) Returns the minimum value from the list given.rnmax(list) Returns the largest value from the given list.rnlen(list) Returns number of elements in a list.rncmp(list1,list2) Compares the two list.rnlist(sequence) Takes sequence types and converts them to lists.