Quiz
Sets in Python
Este quiz tem tempo limite, por isso abre no player de sempre.
Perguntas do quiz (15)
1What is the output of the following ?
sampleSet = {"Yellow", "Orange", "Black"}
sampleSet.add("Blue")
sampleSet.add("Orange")
print(sampleSet)- A{‘Blue’, ‘Orange’, ‘Yellow’, ‘Orange’, ‘Black’}
- B{‘Blue’, ‘Orange’, ‘Yellow’, ‘Black’}
2The union() method returns a new set with all items from both sets by removing duplicates
- AVerdadeiro
- BFalso
3Select all the correct ways to copy two sets
- Aset2 = set1.copy()
- Bset2 = set1
- Cset2 = set(set1)
- Dset2.update(set1)
4What is the output of the following
sampleSet = {"Yellow", "Orange", "Black"}
sampleSet.discard("Blue")
print(sampleSet)- A{‘Yellow’, ‘Orange’, ‘Black’}
- BKeyError: ‘Blue’
5The symmetric_difference() method returns a set that contains all items from both sets, but not the items that are present in both sets.
- AVerdadeiro
- BFalso
6What is the output of the following code
aSet = {1, 'PYnative', ['abc', 'xyz'], True}
print(aSet)- A{1, ‘PYnative’, [‘abc’, ‘xyz’]}
- B{1, ‘PYnative’, [‘abc’, ‘xyz’], True}
- CTypeError
7Select which is true for Python set
- ASets are unordered.
- BSet doesn’t allow duplicate
- Csets are written with curly brackets {}
- Dset Allows duplicate
- Eset is immutable
- Fa set object does support indexing
8What is the output of the following set operation.
set1 = {"Yellow", "Orange", "Black"}
set2 = {"Orange", "Blue", "Pink"}
set1.difference_update(set2)
print(set1)- A{‘Black’, ‘Yellow’}
- B{‘Yellow’, ‘Orange’, ‘Black’, ‘Blue’, ‘Pink’}
9What is the output of the following code
sampleSet = {"Yellow", "Orange", "Black"}
print(sampleSet[1])- AYellow
- BSyntax Error
- COrange
10What is the output of the following union operation
set1 = {10, 20, 30, 40}
set2 = {50, 20, "10", 60}
set3 = set1.union(set2)
print(set3)- A{40, 10, 50, 20, 60, 30}
- B{40, ’10’, 50, 20, 60, 30}
- C{40, 10, ’10’, 50, 20, 60, 30}
- DSynatxError: Different types cannot be used with sets
11What is the output of the following set operation
set1 = {"Yellow", "Orange", "Black"}
set2 = {"Orange", "Blue", "Pink"}
set3 = set2.difference(set1)
print(set3)- A{‘Yellow’, ”Black’, ‘Pink’, ‘Blue’}
- B{‘Pink’, ‘Blue’}
- C{‘Yellow’, ”Black’}
12Select all the correct options to remove “Orange” from the set.
sampleSet = {"Yellow", "Orange", "Black"}- AsampleSet.pop(“Orange”)
- BsampleSet.discard(“Orange”)
- CsampleSet.discard('Orange')
- Ddel sampleSet [“Orange”]
13What is the output of the following
set1 = {10, 20, 30, 40, 50}
set2 = {60, 70, 10, 30, 40, 80, 20, 50}
print(set1.issubset(set2))
print(set2.issuperset(set1))- AFalse
False - BTrue
True - CFalse
True - DTrue
False
- AFalse
14What is the output of the following set operation
sampleSet = {"Yellow", "Orange", "Black"}
sampleSet.update(["Blue", "Green", "Red"])
print(sampleSet)- A{‘Yellow’, ‘Orange’, ‘Red’, ‘Black’, ‘Green’, ‘Blue’}
- B{‘Yellow’, ‘Orange’, ‘Black’, [“Blue”, “Green”, “Red”]}
- CTypeError: update() doesn’t allow list as a argument.
15What is the output of the following code
aSet = {1, 'PYnative', ('abc', 'xyz'), True}
print(aSet)- ATypeError
- B{‘PYnative’, 1, (‘abc’, ‘xyz’), True}
- C{‘PYnative’, 1, (‘abc’, ‘xyz’)}
Informações
- Descrição
- Coding Python Quiz sobre Sets in Python, criado por PathaPadha Support em 27-10-2020.
- Autor
- PathaPadha Support
- Idioma
- English
- Visualizações
- 704
- Etiquetas
- Avaliação
- Ainda sem avaliações Avalie este quiz