赛派号

20款的crv Python Operators

Python Operators ❮ Previous Next ❯ Python Operators

Operators are used to perform operations on variables and values.

In the example below, we use the + operator to add together two values:

Example print(10 + 5) Run example »

Python divides the operators in the following groups:

Arithmetic operators Assignment operators Comparison operators Logical operators Identity operators Membership operators Bitwise operators Python Arithmetic Operators

Arithmetic operators are used with numeric values to perform common mathematical operations:

Operator Name Example Try it + Addition x + y Try it » - Subtraction x - y Try it » * Multiplication x * y Try it » / Division x / y Try it » % Modulus x % y Try it » ** Exponentiation x ** y Try it » // Floor division x // y Try it » Python Assignment Operators

Assignment operators are used to assign values to variables:

Operator Example Same As Try it = x = 5 x = 5 Try it » += x += 3 x = x + 3 Try it » -= x -= 3 x = x - 3 Try it » *= x *= 3 x = x * 3 Try it » /= x /= 3 x = x / 3 Try it » %= x %= 3 x = x % 3 Try it » //= x //= 3 x = x // 3 Try it » **= x **= 3 x = x ** 3 Try it » &= x &= 3 x = x & 3 Try it » |= x |= 3 x = x | 3 Try it » ^= x ^= 3 x = x ^ 3 Try it » >>= x >>= 3 x = x >> 3 Try it »

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至lsinopec@gmail.com举报,一经查实,本站将立刻删除。

上一篇 没有了

下一篇没有了