Python Operators

Division in Python

The double-frontslash // operator performs integer division and the single-frontslash / operator performs float division. An example for integer division is 40//11 = 3. An example for float division is 40/11 = 3.6363636363636362. A crucial lesson you need to master as a programmer is “division in Python”. What does it mean to divide in Python? …

Division in Python Read More »

Python Multiplication Operator

Python’s multiplication operator * multiplies two objects. The semantics of the multiplication depends on the operands’ data types. For example, multiplying two integers performs arithmetic multiplication whereas multiplying a list with an integer performs list concatenation. The specific return value of the multiplication operator is defined in a data types’ __mul__() magic method. Have a …

Python Multiplication Operator Read More »

Python Addition Operator

Python provides the addition operator + to add two objects. The semantics of the addition depends on the operands’ data types. For example, adding two integers perform arithmetic addition whereas adding two lists performs list concatenation. The specific return value of the addition operator is defined in a data types’ __add__() magic method. Have a …

Python Addition Operator Read More »

Python Equal To

The Python equal to (left==right) operator returns True when its left operand is equal to its right operand. Otherwise, it returns False. For example, 3==3 evaluates to True, but 3==2 evaluates to False. Examples Let’s explore a couple of examples regarding the equal to operator. Is 3 equal to 2? What about ‘h’ equal to …

Python Equal To Read More »

Python Less Than

The Python less than (left<right) operator returns True when its left operand is smaller than its right operand. When the left operand is greater than or equal to the right operand, the < operator returns False. For example, 2<3 evaluates to True, but 3<2 and 2<2 both evaluate to False. Examples Let’s explore a couple …

Python Less Than Read More »