micropython/tests/basics/set_binop.py

27 wiersze
1.0 KiB
Python
Czysty Zwykły widok Historia

2014-01-12 23:37:45 +00:00
sets = [set(), {1}, {1, 2}, {1, 2, 3}, {2, 3}, {2, 3, 5}, {5}, {7}]
for s in sets:
for t in sets:
print(sorted(s), '|', sorted(t), '=', sorted(s | t))
print(sorted(s), '^', sorted(t), '=', sorted(s ^ t))
print(sorted(s), '&', sorted(t), '=', sorted(s & t))
print(sorted(s), '-', sorted(t), '=', sorted(s - t))
2014-01-12 23:37:45 +00:00
u = s.copy()
u |= t
print(sorted(s), "|=", sorted(t), '-->', sorted(u))
2014-01-12 23:37:45 +00:00
u = s.copy()
u ^= t
print(sorted(s), "^=", sorted(t), '-->', sorted(u))
2014-01-12 23:37:45 +00:00
u = s.copy()
u &= t
print(sorted(s), "&=", sorted(t), "-->", sorted(u))
2014-01-12 23:37:45 +00:00
u = s.copy()
u -= t
print(sorted(s), "-=", sorted(t), "-->", sorted(u))
2014-01-12 23:09:10 +00:00
print(sorted(s), '==', sorted(t), '=', s == t)
print(sorted(s), '!=', sorted(t), '=', s != t)
print(sorted(s), '>', sorted(t), '=', s > t)
print(sorted(s), '>=', sorted(t), '=', s >= t)
print(sorted(s), '<', sorted(t), '=', s < t)
print(sorted(s), '<=', sorted(t), '=', s <= t)