keys, keys
key values, keys
keys, key values
key values, key values
Union
Intersection
Difference
None of the above
What will be the output of the following Python code?
d = {0, 1, 2}for x in d: print(x)
0 1 2
{0, 1, 2} {0, 1, 2} {0, 1, 2}
error
none of the mentioned
a={5,5,6,7}
a={5,6,7}
Error as there is no add function for set data type
Error as 5 already exists in the set
>>> a={5,6,7}>>> sum(a,5)
5
23
18
Invalid syntax for sum method, too many arguments
{ }
set()
[ ]
( )
Mutable data type
Allows duplicate values
Data type with unordered values
Immutable data type
x | y
x ^ y
x & y
x – y
s={abs}
s={4, ‘abc’, (1,2)}
s={2, 2.2, 3, ‘xyz’}
s={san}
print(len(a))
print(min(a))
a.remove(5)
a[2]=45
>>> a={4,5,6} >>> b={2,8,6} >>> a-b
{4,5}
{6}
Error as unsupported operand type for set data type
Error as the duplicate item 6 is present in both sets
What is the output of the following code?
a = set('dcma')b = set('mlpc')print(a^b)
{‘d’, ‘c’, ‘m’, ‘l’, ‘p’, ‘c’}
{‘m’, ‘l’, ‘p’, ‘c’}
{‘d’, ‘c’, ‘m’, ‘a’}
None of These
pop
remove
update
sum
set
tuple
string
d = {0, 1, 2}for x in d.values(): print(x)
None None None
List
Dictionary
Set
None of the Above
Is the following Python code valid?
a={3,4,{7,5}}print(a[2][0])
Yes, 7 is printed
Error, elements of a set can’t be printed
Error, subsets aren’t allowed
Yes, {7,5} is printed
d = {0, 1, 2}for x in d: print(d.add(x))
0 1 2 0 1 2 0 1 2 …
None of the mentioned
s2.issubset(s1)
s2.issuperset(s1)
s1.issuperset(s2)
s1.isset(s2)
a={5,6,7,8}b={7,8,9,10} print(len(a+b))
8
Error, unsupported operand ‘+’ for sets
6
Nothing is displayed
discard
dispose
What will the output of following code?
a={1,2,3}b={1,2,3,4}c=a.issuperset(b)print(c)
False
True
Syntax error for issuperset() method
Error, no method called issuperset() exists