gs gs109 Python Sets - Python Sets - Quiz No.5
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 2: What will be the output of the following Python code snippet?
z=set('abc$de') 'a' in z
True
False
No output
Error
Question 3: What will be the output of the following Python code snippet?
z=set('abc') z.add('san') z.update(set(['p', 'q'])) z
{‘abc’, ‘p’, ‘q’, ‘san’}
{‘a’, ‘b’, ‘c’, [‘p’, ‘q’], ‘san}
{‘a’, ‘c’, ‘c’, ‘p’, ‘q’, ‘s’, ‘a’, ‘n’}
{‘a’, ‘b’, ‘c’, ‘p’, ‘q’, ‘san’}
Question 4: What will be the output of the following Python code snippet?
s=set([1, 2, 3]) s.union([4, 5]) s|([4, 5])
{1, 2, 3, 4, 5} {1, 2, 3, 4, 5}
Error {1, 2, 3, 4, 5}
{1, 2, 3, 4, 5} Error
Error Error
Question 5: What will be the output of the following Python code snippet?
for x in set('pqr'): print(x*2)
pp qq rr
pqr pqr
ppqqrr
pqrpqr
Question 6: What will be the output of the following Python code snippet?
{a**2 for a in range(4)}
{1, 4, 9, 16}
{0, 1, 4, 9, 16}
Error
{0, 1, 4, 9}
Question 7: What will be the output of the following Python function?
{x for x in 'abc'} {x*3 for x in 'abc'}
{abc} aaa bbb ccc
abc abc abc abc
{‘a’, ‘b’, ‘c’} {‘aaa’, ‘bbb’, ‘ccc’}
{‘a’, ‘b’, ‘c’} abc abc abc
Question 9: What will be the output of the following Python code snippet?
a=[1, 4, 3, 5, 2] b=[3, 1, 5, 2, 4] a==b set(a)==set(b)
True False
False False
False True
True True
Question 10: What will be the output of the following Python code snippet?
l=[1, 2, 4, 5, 2, 'xy', 4] set(l) l
{1, 2, 4, 5, 2, ‘xy’, 4} [1, 2, 4, 5, 2, ‘xy’, 4]
{1, 2, 4, 5, ‘xy’} [1, 2, 4, 5, 2, ‘xy’, 4]
{1, 5, ‘xy’} [1, 5, ‘xy’]
{1, 2, 4, 5, ‘xy’} [1, 2, 4, 5, ‘xy’]