gs gs109 Python Sets - Python Sets - Quiz No.1
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: Which of these about a set is not true?
Mutable data type
Does not allow duplicate values
Data type with unordered values
Immutable data type
Question 2: Which of the following is not the correct syntax for creating a set?
set([[1,2],[3,4]])
set([1,2,2,3,4])
set((1,2,3,4))
{1,2,3,4}
Question 3: What will be the output of the following Python code?
nums = set([1,1,2,3,3,3,4,4]) print(len(nums))
7
Error, invalid syntax for formation of set
4
8
Question 6: What will be the output of the following Python code?
>>> a={5,4} >>> b={1,2,4,5} >>> a<b
{1,2}
True
False
Invalid operation
Question 7: If a={5,6,7,8}, which of the following statements is false?
print(len(a))
print(min(a))
a.remove(5)
a[2]=45
Question 8: If a={5,6,7}, what happens when a.add(5) is executed?
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
Question 9: What will be the output of the following Python code?
>>> a={4,5,6} >>> b={2,8,6} >>> a+b
{4,5,6,2,8}
{4,5,6,2,8,6}
Error as unsupported operand type for sets
Error as the duplicate item 6 is present in both sets
Question 10: What will be the output of the following Python code?
>>> 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