学习内容
x, y = 4, 5
small = x if x < y else y
print(small)
a = ["hello"]
b = ["hello"]
print(a is b, a == b)
import decimal
from decimal import Decimal
b = Decimal(1) / Decimal(3)
print(b)
decimal.getcontext().prec = 4
c = Decimal(1) / Decimal(3)
print(c)
print(*objects, sep=' ', end='\n', file=sys.stdout, flush=False)
00 00 00 11 -> 3
10 00 00 11 -> -3
00 00 00 11 -> 3
11 11 11 00 -> -3
00 00 00 11 -> 3
11 11 11 01 -> -3
n << 1 -> 计算 n*2
n >> 1 -> 计算 n/2,负奇数的运算不可用
n << m -> 计算 n*(2^m),即乘以 2 的 m 次方
n >> m -> 计算 n/(2^m),即除以 2 的 m 次方
1 << n -> 2^n
a ^= b
b ^= a
a ^= b
00 00 01 01 -> 5
&
11 11 10 11 -> -5
---
00 00 00 01 -> 1
00 00 11 10 -> 14
&
11 11 00 10 -> -14
---
00 00 00 10 -> 2
my_list = ['lsgogroup']
my_list.pop(0)
assert len(my_list) > 0
assert 3 > 7
enumerate(sequence, [start=0])
[ expr for value in collection [if condition] ]
a = [(i, j) for i in range(0, 3) if i < 1 for j in range(0, 3) if j > 1]
print(a)
|