Thursday, September 10, 2026

Python Set Quiz

 Python Set Quiz


1. What is the output? s = {1, 2, 2, 3, 3} print(len(s))

   A. 2

   B. 3

   C. 5

   D. 4


2. What is the output? s = {10, 20, 30} print(20 in s)

   A. 20

   B. False

   C. None

   D. True


3. What is the output? s = {1, 2, 3} s.add(4) print(len(s))

   A. 4

   B. 5

   C. 3

   D. 1


4. What is the output? A = {1, 2, 3} B = {3, 4, 5} print(A & B)

   A. {3}

   B. {4, 5}

   C. {1, 2}

   D. {1, 2, 3, 4, 5}


5. What is the output? A = {1, 2} B = {2, 3} print(A | B)

   A. {3}

   B. {2}

   C. {1, 2, 3}

   D. {1}


6. What is the output? A = {1, 2, 3, 4} B = {2, 4} print(A - B)

   A. {2, 4}

   B. {1, 3}

   C. {2}

   D. {1, 2, 3, 4}


7. What is the output? s = set([1, 1, 2, 2, 3]) print(s)

   A. {1, 2, 3}

   B. [1, 2, 3]

   C. {1, 2, 2, 3}

   D. {1, 1, 2, 2, 3}


8. What is the output? s = {5, 10, 15} s.remove(10) print(10 in s)

   A. None

   B. True

   C. False

   D. 10


9. What is the output? s = {1, 2, 3} s.add(2) print(len(s))

   A. 4

   B. 3

   C. 1

   D. 2


10. What is the output? s = {2, 4, 6} print(5 not in s)

   A. False

   B. None

   C. True

   D. 5

Wednesday, September 9, 2026

Ace Your Next Coding Interview: Top 10 Essential Python Q&As

Ace Your Next Coding Interview: Top 10 Essential Python Q&As

1. What is the difference between a list and a tuple?

 * List is mutable

 * Tuple is immutable

2. What is the difference between a list and a dictionary?

 * List stores ordered values

 * Dictionary stores key value pairs

3. What is a lambda function?

 * A small anonymous function

 * Used for short operations

4. What is list comprehension?

 * A concise way to create lists

 * Faster and cleaner than loops

5. What is the difference between == and is?

 * == compares values

 * is compares memory location

6. What are decorators?

 * Functions that modify other functions

 * Used for logging, validation, caching

7. What is a generator?

 * A function that yields values one by one

 * Saves memory

8. What is the difference between deep copy and shallow copy?

 * Shallow copy copies references

 * Deep copy copies full data

9. What is exception handling?

 * Handles errors using try except

 * Prevents program crash

10. What is the GIL in Python?

 * Global Interpreter Lock

 * Allows one thread to execute at a time