Home >Backend Development >Python Tutorial >What are the meanings of python arithmetic symbols?
Python operation symbol meaning: 1. Plus sign ( ): used for addition operation; 2. Minus sign (-): used for subtraction operation; 3. Multiplication sign (*): used for multiplication operation; 4 , Division sign (/): used for division operations; 5. Modulo operator (%): returns the remainder of division; 6. Power operator ()**: used for exponential operations; 7. Integer division operator (// ): Returns the integer result of division; 8. Assignment operator (=): used for assignment; 9. Comparison operator: used to compare the size of two values; 10. Logical operator: used to combine Boolean expressions.
The operating system for this tutorial: Windows 10 system, Python version 3.11.4, Dell G3 computer.
The operation symbols and their meanings in Python are as follows:
1. Plus sign ( ): used for addition operations.
python
a = 2 b = 3 c = a + b # c的值为5
2. Minus sign (-): used for subtraction operations.
python
a = 5 b = 3 c = a - b # c的值为2
3. Multiplication sign (*): used for multiplication operations.
python
a = 2 b = 3 c = a * b # c的值为6
4. Division sign (/): used for division operations.
python
a = 10 b = 2 c = a / b # c的值为5.0(浮点数结果)
5. Modulo operator (%): Returns the remainder of division.
python
a = 10 b = 3 c = a % b # c的值为1
6. Power operator ()**: used for exponential operations.
python
a = 2 b = 3 c = a ** b # c的值为8(2的3次方)
7. Integer division operator (//): Returns the integer result of division.
python
a = 10 b = 3 c = a // b # c的值为3(整数结果)
8. Assignment operator (=): used for assignment.
python
a = 5 # 将5赋值给a
9. Comparison operator: used to compare the size of two values. Return True or False.
==: equal to (equal operator)
!=: not equal to (not equal to operator)
>: greater than (greater than operator)
<: less than (less than operator)
>=: greater than or equal to (greater than or equal to operator)
<=: less than or equal to (less than or equal to operator) (symbol)
10. Logical operators: used to combine Boolean expressions.
and: logical AND (if both operands are True, the result is True)
or: logical OR (if at least one of the two operands is True, the result is True)
not: logical NOT (reverse the Boolean value of the operand)
The above is the detailed content of What are the meanings of python arithmetic symbols?. For more information, please follow other related articles on the PHP Chinese website!