GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Quiz

Sets in Python

PathaPadha Support 15 Fragen

Quiz starten

Dieses Quiz hat ein Zeitlimit und öffnet sich deshalb im gewohnten Player.

Fragen in diesem Quiz (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. ARichtig
    2. BFalsch
  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. ARichtig
    2. BFalsch
  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

Informationen

Beschreibung
Coding Python Quiz am Sets in Python, erstellt von PathaPadha Support am 27/10/2020.
Sprache
English
Aufrufe
704
Schlagwörter
pythoncoding
Bewertung
Noch keine Bewertungen
Bewerte dieses Quiz
Bewerte dieses Quiz

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck