mirror of https://github.com/astral-sh/ruff
34 lines
397 B
Python
34 lines
397 B
Python
# Simple
|
|
1 + 2
|
|
1 - 2
|
|
1 * 2
|
|
1 / 2
|
|
1 // 2
|
|
1 % 2
|
|
1 ** 2
|
|
1 | 2
|
|
1 ^ 2
|
|
1 & 2
|
|
1 >> 2
|
|
1 << 2
|
|
1 @ 2
|
|
|
|
# Same precedence
|
|
1 + 2 - 3 + 4
|
|
1 * 2 / 3 // 4 @ 5 % 6
|
|
1 << 2 >> 3 >> 4 << 5
|
|
|
|
# Different precedence
|
|
1 + 2 * 3
|
|
1 * 2 + 3
|
|
1 ** 2 * 3 - 4 @ 5 + 6 - 7 // 8
|
|
# With bitwise operators
|
|
1 | 2 & 3 ^ 4 + 5 @ 6 << 7 // 8 >> 9
|
|
|
|
# Associativity
|
|
1 + (2 + 3) + 4
|
|
1 + 2 + (3 + 4 + 5)
|
|
|
|
# Addition with a unary plus
|
|
x ++ y
|