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.

31 lines
929 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(r(s), '|', r(t), '=', r(s | t))
print(r(s), '^', r(t), '=', r(s ^ t))
print(r(s), '&', r(t), '=', r(s & t))
print(r(s), '-', r(t), '=', r(s - t))
u = s.copy()
u |= t
print(r(s), "|=", r(t), '-->', r(u))
u = s.copy()
u ^= t
print(r(s), "^=", r(t), '-->', r(u))
u = s.copy()
u &= t
print(r(s), "&=", r(t), "-->", r(u))
u = s.copy()
u -= t
print(r(s), "-=", r(t), "-->", r(u))
print(r(s), '==', r(t), '=', s == t)
print(r(s), '!=', r(t), '=', s != t)
print(r(s), '>', r(t), '=', s > t)
print(r(s), '>=', r(t), '=', s >= t)
print(r(s), '<', r(t), '=', s < t)
print(r(s), '<=', r(t), '=', s <= t)