Search Header Logo

PYTHON SET

Authored by Dr.S.Vidhya KGCAS

Information Technology (IT)

Professional Development

Used 5+ times

PYTHON SET
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

5 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is the correct way to create an empty set in Python?

  • set = {}

  • set()

  • []

  • ()

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you add an element 'x' to a set s?

  • s.add('x')

  • s.append('x')

  • s.insert('x')

  • s.extend('x')

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the result of the following code?

s = {1, 2, 3}

s.discard(4)

  • Raises a KeyError

  • Removes 4 from the set

  • adds 4 to the set

  • Does nothing

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following operations will return the union of two sets a and b?

  • a.union(b)

  • a + b

  • a | b

  • Both A and C

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of the difference() method in Python sets?

  • ATo find elements present in both sets

  • To find elements present in the first set but not in the second

  • To remove common elements

  • To add elements from two sets

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?