¡GoConqr estrena diseño! Cuéntanos qué te parece.

Test

Sets in Python

PathaPadha Support 15 preguntas

Hacer el test

Este test tiene tiempo límite, así que se abre en el reproductor de siempre.

Preguntas del test (15)

  1. 1What is the output of the following ?

    sampleSet = {"Yellow", "Orange", "Black"}
    sampleSet.add("Blue")
    sampleSet.add("Orange")
    print(sampleSet)
    1. A{‘Blue’, ‘Orange’, ‘Yellow’, ‘Orange’, ‘Black’}
    2. B{‘Blue’, ‘Orange’, ‘Yellow’, ‘Black’}
  2. 2The union() method returns a new set with all items from both sets by removing duplicates
    1. AVerdadero
    2. BFalso
  3. 3Select all the correct ways to copy two sets
    1. Aset2 = set1.copy()
    2. Bset2 = set1
    3. Cset2 = set(set1)
    4. Dset2.update(set1)
  4. 4What is the output of the following

    sampleSet = {"Yellow", "Orange", "Black"}
    sampleSet.discard("Blue")
    print(sampleSet)
    1. A{‘Yellow’, ‘Orange’, ‘Black’}
    2. BKeyError: ‘Blue’
  5. 5The symmetric_difference() method returns a set that contains all items from both sets, but not the items that are present in both sets.
    1. AVerdadero
    2. BFalso
  6. 6What is the output of the following code

    aSet = {1, 'PYnative', ['abc', 'xyz'], True}
    print(aSet)
    1. A{1, ‘PYnative’, [‘abc’, ‘xyz’]}
    2. B{1, ‘PYnative’, [‘abc’, ‘xyz’], True}
    3. CTypeError
  7. 7Select which is true for Python set
    1. ASets are unordered.
    2. BSet doesn’t allow duplicate
    3. Csets are written with curly brackets {}
    4. Dset Allows duplicate
    5. Eset is immutable
    6. Fa set object does support indexing
  8. 8What is the output of the following set operation.

    set1 = {"Yellow", "Orange", "Black"}
    set2 = {"Orange", "Blue", "Pink"}

    set1.difference_update(set2)
    print(set1)
    1. A{‘Black’, ‘Yellow’}
    2. B{‘Yellow’, ‘Orange’, ‘Black’, ‘Blue’, ‘Pink’}
  9. 9What is the output of the following code

    sampleSet = {"Yellow", "Orange", "Black"}
    print(sampleSet[1])
    1. AYellow
    2. BSyntax Error
    3. COrange
  10. 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)
    1. A{40, 10, 50, 20, 60, 30}
    2. B{40, ’10’, 50, 20, 60, 30}
    3. C{40, 10, ’10’, 50, 20, 60, 30}
    4. DSynatxError: Different types cannot be used with sets

Información

Descripción
Coding Python Test sobre Sets in Python, creado por PathaPadha Support el 27/10/2020.
Idioma
English
Visitas
704
Etiquetas
pythoncoding
Valoración
Aún sin valoraciones
Valora este test
Valora este test

Escríbenos

¿Sobre qué es tu mensaje?

¿Qué te parece el nuevo diseño?

¿Te gusta?