You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
845 B
30 lines
845 B
def r(s):
|
|
l = list(s)
|
|
l.sort()
|
|
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))
|
|
|
|
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)
|
|
|