Python Test 6 - Sets

Which of these about a set is not true?

Which of the following is not the correct syntax for creating a set?

What will be the output of the following Python code?

nums = set([1,1,2,3,3,3,4,4])
print(len(nums))

What will be the output of the following Python code?

a = [5,5,6,7,7,7]
b = set(a)
def test(lst):
if lst in b:
return 1
else:
return 0
for i in filter(test, a):
print(i,end=" ")

Which of the following statements is used to create an empty set?

What will be the output of the following Python code?

a={5,4}
b={1,2,4,5}
a<b

If a={5,6,7,8}, which of the following statements is false?

If a={5,6,7}, what happens when a.add(5) is executed?

What will be the output of the following Python code?

a={4,5,6}
b={2,8,6}
a+b

What will be the output of the following Python code?

a={4,5,6}
b={2,8,6}
a-b

What will be the output of the following Python code?

a={5,6,7,8}
b={7,8,10,11}
a^b

What will be the output of the following Python code?

s={5,6}
s*3

What will be the output of the following Python code?

a={5,6,7,8}
b={7,5,6,8}
a==b

What will be the output of the following Python code?

a={3,4,5}
b={5,6,7}
a|b

Is the following Python code valid?

a={3,4,{7,5}}
print(a[2][0])

Schreibe einen Kommentar