Skip to content
VUBuddy

CS306 Quiz 4

Introduction to Python PDF 846 KBUpdated 23 Oct 2026
Quiz CS306 Quiz 4 PDF 846 KB
vubuddy.com
Type
Quiz
Course
CS306 Introduction to Python
Size
PDF 846 KB
Updated
23 Oct 2026
Free download 0 of 3 used today
Download free · 846 KB

You get 3 free files a day on the website. Add the Chrome extension for 30 a day.

Unlimited downloads in the Android app Get it free on Google Play

Preview text

Text from pages 1, 2 of 2. Download the file for all 2 pages.

Q1. Which of the following is true about iterating through a set?

  1. Sets are unordered, so iteration may not follow insertion order
  2. You cannot iterate over a set
  3. Sets support list slicing for iteration
  4. Sets are indexed, and you can use the index to iterate

Correct answer: Sets are unordered, so iteration may not follow insertion order

Q2. How can multiple elements be added to a set at once?

  1. extend()
  2. add()
  3. update()
  4. append()

Correct answer: update()

Q3. What happens when a duplicate element is added to a set?

  1. The duplicate is ignored
  2. The set throws an error
  3. The duplicate is added at the end
  4. The set grows in size

Correct answer: The duplicate is ignored

Q4. Which of the following is true about variable-length unpacking in Python?

  1. The * operator can be used with strings and tuples, but not lists
  2. You cannot use * for unpacking a tuple
  3. You can only use * with lists
  4. The * operator captures all remaining elements during unpacking

Correct answer: The * operator captures all remaining elements during unpacking

Q5. How can you repeat the elements of a tuple (1, 2) three times?

  1. tuple(1, 2).repeat(3)
  2. (1, 2).repeat(3)
  3. (1, 2) * 3
  4. (1, 2) + 3

Correct answer: (1, 2) * 3

Q6. How would you unpack a list l = [1, 2, 3] into individual variables?

  1. a = l[0], b = l[1]
  2. a, *b = l
  3. a, b = l
  4. a, b, c = l

Correct answer: a, b = l

Q7. What does Python's consistency refer to in handling data structures?

  1. Lists and strings are treated as mutable
  2. Similar operations are available for different data structures
  3. Python only supports immutable data structures
  4. Lists and strings are immutable

Correct answer: Similar operations are available for different data structures

Q8. In which scenario "set" is most useful?

  1. When you need to access elements by index
  2. When you need to preserve the order of elements
  3. When you need to modify elements in place
  4. When you need to store unique elements

Correct answer: When you need to store unique elements

Q9. Which of the following is a property of sets in Python?

  1. Sets can contain only numbers
  2. Sets allow duplicate elements
  3. Sets are ordered
  4. Sets do not allow duplicate elements

Correct answer: Sets do not allow duplicate elements

Q10. How can you find the index of element 30 in a tuple t = (10, 20, 30, 40)?

  1. t.search(30)
  2. index(t, 30)
  3. find(30, t)
  4. t.index(30)

Correct answer: t.index(30)

CS306 Introduction to Python All CS306 handouts, past papers, quizzes and MCQs in one place. Open course page

Get more out of VUBuddy, for free

Android app Free on Google Play
  • Unlimited downloads
  • The explanation behind every MCQ answer
  • Study offline on slow data
Get the Android app
Chrome extension Free on the Chrome Web Store
  • 30 downloads a day instead of 3
  • Sign in and buy Pro Semester here
Add to Chrome

One Pro Semester membership works in both the extension and the app.