Skip to content
VUBuddy

CS306 Quiz 3

Introduction to Python PDF 846 KBUpdated 23 Oct 2026
Quiz CS306 Quiz 3 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 indexed, and you can use the index to iterate
  2. You cannot iterate over a set
  3. Sets are unordered, so iteration may not follow insertion order
  4. Sets support list slicing for iteration

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

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

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

Correct answer: When you need to store unique elements

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

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

Correct answer: t.index(30)

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

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

Correct answer: update()

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

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

Correct answer: (1, 2) * 3

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

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

Correct answer: Similar operations are available for different data structures

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

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

Correct answer: a, b, c = l

Q8. Which method is used to add a single element to a set?

  1. append()
  2. insert()
  3. add()
  4. push()

Correct answer: add()

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

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

Correct answer: The duplicate is ignored

Q10. 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 can only use * with lists
  3. You cannot use * for unpacking a tuple
  4. The * operator captures all remaining elements during unpacking

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

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.