set1 ={3, 4, 5},则可以用set1[0]来输出集合第一个元素()
举一反三
- set1 = {x for x in range(10)} print(set1) 以上代码的运行结果为? A: {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} B: {0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10} C: {1, 2, 3, 4, 5, 6, 7, 8, 9} D: {1, 2, 3, 4, 5, 6, 7, 8, 9,10}
- set1 = {x for x in range(10) if x%2!=0} set1.remove(1) print(set1) 以上代码的运行结果为? A: {1, 3, 5, 7, 9} B: {1, 3, 5, 7} C: {3, 5, 7, 9} D: {3, 5, 7}
- set1 = {1, 2, 3} set2 = set1.copy() set3 =set1 set4=set(set1) 针对以上程序,当对set1进行修改时,以下说法正确的是()。 A: set2发生改变 B: set3发生改变 C: set4发生改变 D: set2 , set3和set4都发生改变
- set1 = {x for x in range(10) if x%2!=0} print(set1) 以上代码的运行结果为? A: {1, 3, 5, 7, 9} B: {1, 3, 5, 7} C: {3, 5, 7, 9} D: {3, 5, 7}
- 以下程序的执行结果是 set1 = {1, 2, 3} set2 = set1.copy() set2.add(4) print(set1) A: {1, 2, 3, 4} B: {1, 2, 3} C: None D: 程序报错