2014-01-12 18:09:10 -05:00
|
|
|
def r(s):
|
|
|
|
l = list(s)
|
|
|
|
l.sort()
|
2014-01-12 18:37:45 -05:00
|
|
|
return l
|
|
|
|
sets = [set(), {1}, {1, 2}, {1, 2, 3}, {2, 3}, {2, 3, 5}, {5}, {7}]
|
|
|
|
for s in sets:
|
|
|
|
for t in sets:
|
|
|
|
print(s, '|', t, '=', r(s | t))
|
|
|
|
print(s, '^', t, '=', r(s ^ t))
|
|
|
|
print(s, '&', t, '=', r(s & t))
|
|
|
|
print(s, '-', t, '=', r(s - t))
|
|
|
|
u = s.copy()
|
|
|
|
u |= t
|
|
|
|
print(s, "|=", t, '-->', r(u))
|
|
|
|
u = s.copy()
|
|
|
|
u ^= t
|
|
|
|
print(s, "^=", t, '-->', r(u))
|
|
|
|
u = s.copy()
|
|
|
|
u &= t
|
|
|
|
print(s, "&=", t, "-->", r(u))
|
|
|
|
u = s.copy()
|
|
|
|
u -= t
|
|
|
|
print(s, "-=", t, "-->", r(u))
|
2014-01-12 18:09:10 -05:00
|
|
|
|
2014-01-12 18:37:45 -05:00
|
|
|
print(s, '==', t, '=', s == t)
|
|
|
|
print(s, '!=', t, '=', s != t)
|
|
|
|
print(s, '>', t, '=', s > t)
|
|
|
|
print(s, '>=', t, '=', s >= t)
|
|
|
|
print(s, '<', t, '=', s < t)
|
|
|
|
print(s, '<=', t, '=', s <= t)
|