gs gs109 Python Sets - Python Sets - Quiz No.3
gs gs109 Python Quiz
This quiz belongs to book/course code gs gs109 Python of gs organization. We have 134 quizzes available related to the book/course Python. This quiz has a total of 10 multiple choice questions (MCQs) to prepare and belongs to topic Python Sets. NVAEducation wants its users to help them learn in an easy way. For that purpose, you are free to prepare online MCQs and quizzes.
NVAEducation also facilitates users to contribute in online competitions with other students to make a challenging situation to learn in a creative way. You can create one to one, and group competition on an topic of a book/course code. Also on NVAEducation you can get certifications by passing the online quiz test.
Question 1: What will be the output of the following Python code?
>>> a={1,2,3} >>> a.intersection_update({2,3,4,5}) >>> a
{2,3}
Error, duplicate item present in list
Error, no method called intersection_update for set data type
{1,4,5}
Question 2: What will be the output of the following Python code?
>>> a={1,2,3} >>> b=a >>> b.remove(3) >>> a
{1,2,3}
Error, copying of sets isn’t allowed
{1,2}
Error, invalid syntax for remove
Question 3: What will be the output of the following Python code?
>>> a={1,2,3} >>> b=a.copy() >>> b.add(4) >>> a
{1,2,3}
Error, invalid syntax for add
{1,2,3,4}
Error, copying of sets isn’t allowed
Question 4: What will be the output of the following Python code?
>>> a={1,2,3} >>> b=a.add(4) >>> b
0
{1,2,3,4}
{1,2,3}
Nothing is printed
Question 5: What will be the output of the following Python code?
>>> a={1,2,3} >>> b=frozenset([3,4,5]) >>> a-b
{1,2}
Error as difference between a set and frozenset can’t be found out
Error as unsupported operand type for set data type
frozenset({1,2})
Question 6: What will be the output of the following Python code?
>>> a={5,6,7} >>> sum(a,5)
5
23
18
Invalid syntax for sum method, too many arguments
Question 7: What will be the output of the following Python code?
>>> a={1,2,3} >>> {x*2 for x in a|{4,5}}
{2,4,6}
Error, set comprehensions aren’t allowed
{8, 2, 10, 4, 6}
{8,10}
Question 8: What will be the output of the following Python code?
>>> a={5,6,7,8} >>> b={7,8,9,10} >>> len(a+b)
8
Error, unsupported operand ‘+’ for sets
6
Nothing is displayed
Question 9: What will be the output of the following Python code?
a={1,2,3} b={1,2,3} c=a.issubset(b) print(c)
True
Error, no method called issubset() exists
Syntax error for issubset() method
False
Question 10: Is the following Python code valid?
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