小编Tim*_*ugh的帖子

Python集操作-集的补集并集

我正在参加离散数学课程,并试图复制De Morgan的定律

补码(B联合C)=补码(B)与补码(C)相交。

我尝试搜索Python在集合上执行补码的能力,但没有发现太多。

所以我只是在IDLE中尝试过。这看起来正确吗?

U = {'pink', 'purple', 'red', 'blue', 'gray', 'orange', 'green', 'yellow', 'indigo', 'violet'}
A = {'purple', 'red', 'orange', 'yellow', 'violet'}
B = {'blue', 'gray', 'orange', 'green'}
C = {'pink', 'red','blue','violet'}
Comp_B = U - B
Comp_C = U - C
Comp_Union_BC = Comp_B.intersection(Comp_C)
print(Comp_Union_BC)
Run Code Online (Sandbox Code Playgroud)

python discrete-mathematics

4
推荐指数
1
解决办法
1216
查看次数

标签 统计

discrete-mathematics ×1

python ×1