A tuple consists of a number of values represented by commas and enclosed within parentheses. We cannot change the values in a tuple after creating it. Actually, a tuple is a read-only data type. The values stored in a tuple ...
vinish.ai Latest Articles
Lists in Python
ShibuA list consists of items separated by commas and enclosed within square brackets ([]). Lists are similar to arrays. Actually, an array contains values of a similar data type, a list, on the other hand, can have to belong to ...
Slice a String in Python
ShibuWe can extract subsets of strings by using the slice operator ([] and [:]). We need to specify the index or the range of characters to be extracted. Actually, 0 is the index of the first character, and n-1 is ...
String Repetition in Python
ShibuBasically, we cannot add a string and a number, but we can definitely multiply a string and a number. When a string is multiplied with an integer n, the string is repeated n times. The * operator is known as ...
String concatenation in Python
ShibuIn Python, we can add two strings. The process of combining two strings is called concatenation. Two strings, whether created using single or double quotes, are concatenated in the same way. Python Concatenation Examples Example: 1 a=”Apple is Red.” b=”Apple ...
Types of Expression in Python
ShibuPython supports the following types of expression: Infix Expression In Infix expression, the operator is placed in between the operands. For example, a=b-c Prefix Expression In the Prefix expression, the operator is placed before the operands. For example, a=+bc Postfix ...
What is Expression in Python?
ShibuIn python, an expression is any legal combination of symbols (like a variable, constants, and operators) representing a value. An expression must have at least one operand (variable or constant) and have one or more operators. After evaluating an expression, ...
Operators Precedence and Associativity in Python
ShibuWhen an expression has more than one operator, then it is the relative priorities of the operators with respect to each other that determine the order in which the expression is evaluated. Actually, there are distinct levels of precedence, and ...
Identity Operators in Python
ShibuIdentity operator compares the memory locations of two objects. Python supports the following Identity Operators: IS Operator IS NOT Operator IS Operator This operator returns True if operands or value on both sides of the operator point to the same ...
Membership Operators in Python
ShibuMembership Operators, as the name suggests, test for membership in a sequence such as strings, lists, or tuples. Python supports the following membership operators: IN Operator NOT IN Operator IN Operator This operator returns True if a variable is found ...