Python期末考试-集合问题
来源:互联网 发布:java ftp断点上传 编辑:程序博客网 时间:2024/05/21 16:57
产生两个集合,各包含20个[1,200]范围内的随机整数,计算着两个集合的交集和并集,并输出结果。
这是一道简单题,以下是我的代码。
import randomlistRandom = [random.randint(1,200) for i in range(20)]ListRandom = [random.randint(1,200) for i in range(20)]A = set(listRandom)B = set(ListRandom)C = A.intersection(B)D = A.union(B)print("A是:")print (A)print()print("B是:")print (B)print()print("A与B的交集是:")print(C)print()print("A与B的并集是:")print(D)print()
0 0
- Python期末考试-集合问题
- Python期末考试-中心点问题
- python使用问题集合
- 大一下期末考试:排序问题
- 期末考试
- 期末考试
- 期末考试
- 期末考试????
- 期末考试
- 期末考试......
- 期末考试
- 期末考试
- 期末考试
- ubuntu下python问题集合
- 爬虫入门:Python (问题集合)
- 期末考试-怀表问题(算法基础 第10周)
- python 集合
- python集合
- JavaScript基础系列15---原型
- 平时积累
- 递归查询某路径下的指定文件路径
- PHP运行环境(Apache配置、Mysql)搭建安装详细说明
- 炫酷的导航条
- Python期末考试-集合问题
- 12. vim 编辑器
- eclipse下,maven Build项目出错
- 每天一个Linux命令(1):ls命令
- angular.foreach 循环使用方法
- useradd 与adduser的区别
- 【3-1-30】动态内存分配
- 找到内核中的所有对象是通过什么模型结构串起来维护的,就掌握了这套代码
- Python: 3行代码实现txt文件转csv