Detail Description about Python StringsPosted by Infocampus HR on December 28th, 2017 Accessing Strings:
Strings OperatorsThere are basically 3 types of Operators supported by String:
Basic Operators:There are two types of basic operators in String. They are "+" and "*". String Concatenation Operator :(+)The concatenation operator (+) concatenate two Strings and forms a new String. Replication Operator: (*)Replication operator uses two parameter for operation. One is the integer value and the other one is the String. The 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. Membership OperatorsMembership Operators are already discussed in the Operators section. Let see with context of String. There are two types of Membership operators: 1) in:"in" operator return true if a character or the entire substring is present in the specified string, otherwise false. 2) not in:"not in" operator return true if a character or entire substring does not exist in the specified string, otherwise false. Relational Operators:All 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). Slice Notation:String slice can be defined as substring which is the part of string. Therefore further substring can be obtained from a string. There 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. String Functions and Methods:There are many predefined or built in functions in String. They are as follows:
Python List1).Python lists are the data structure that is capable of holding different type of data. 2).Python lists are mutable i.e., Python will not create a new list if we modify an element in the list. 3).It is a container that holds other objects in a given order. Different operation like insertion and deletion can be performed on lists. 4).A list can be composed by storing a sequence of different type of values separated by commas. 5).A python list is enclosed between square([]) brackets. 6).The elements are stored in the index basis with starting index as 0. List Operations:Various Operations can be performed on List. Operations performed on List are given as: a) Adding Lists: Lists can be added by using the concatenation operator(+) to join two lists. Functions and Methods of Lists:There are many Built-in functions and methods for Lists. They are as follows: There are following List functions:
Like it? Share it!More by this author |