filmov
tv
Arithmetic Operators In Python | Python Beginner to Advance | Full Course

Показать описание
In Python, arithmetic operators are used to perform mathematical operations on numeric values. Here are the commonly used arithmetic operators in Python:
Addition (+): Adds two operands.
Example: 3 + 4 equals 7.
Subtraction (-): Subtracts the second operand from the first.
Example: 5 - 2 equals 3.
Multiplication (*): Multiplies two operands.
Example: 2 * 3 equals 6.
Division (/): Divides the first operand by the second operand, returning a floating-point result.
Example: 7 / 2 equals 3.5.
Floor Division (//): Performs integer division, discarding the remainder.
Example: 7 // 2 equals 3.
Modulus (%): Returns the remainder of the division.
Example: 7 % 2 equals 1.
Exponentiation (**): Raises the first operand to the power of the second operand.
Example: 2 ** 3 equals 8.
It's worth noting that the division operator (/) returns a floating-point result even if the operands are integers. If you specifically want integer division, you can use the floor division operator (//).
Addition (+): Adds two operands.
Example: 3 + 4 equals 7.
Subtraction (-): Subtracts the second operand from the first.
Example: 5 - 2 equals 3.
Multiplication (*): Multiplies two operands.
Example: 2 * 3 equals 6.
Division (/): Divides the first operand by the second operand, returning a floating-point result.
Example: 7 / 2 equals 3.5.
Floor Division (//): Performs integer division, discarding the remainder.
Example: 7 // 2 equals 3.
Modulus (%): Returns the remainder of the division.
Example: 7 % 2 equals 1.
Exponentiation (**): Raises the first operand to the power of the second operand.
Example: 2 ** 3 equals 8.
It's worth noting that the division operator (/) returns a floating-point result even if the operands are integers. If you specifically want integer division, you can use the floor division operator (//).