• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 2 out of 15 pages
Exam (elaborations)

Inf1511-Mcq-Pack.

Document preview thumbnail
Preview 2 out of 15 pages

1. Which of the following are true for objects of Python’s set type: The order of elements in a set is significant. A given element can’t appear in a set more than once. A set may contain elements that are mutable. Sets are mutable. 2. Which of the following define the set {'a', 'b', 'c'}: s = {('a', 'b', 'c')} s = set('a', 'b', 'c') s = {'a', 'b', 'c'} s = set('abc') s = set(['a', 'b', 'c']) 3. What Python expression tests whether the string 'foo' is a member of set s? 'foo' in s 4. You have a set s defined as follows: s = {100, 200, 300} Which one of the following statements does not correctly produce the union of s and the set {300, 400, 500}: s | [300, 400, 500] s | {300, 400, 500} ({300, 400, 500}) s | set([300, 400, 500]) ([300, 400, 500]) (set([300, 400, 500])) INF1511-MCQ-PACK. 5. What is the result of this statement: {'b', 'a', 'r'} & set('qux') {'b', 'r', 'a'} {'q', 'r', 'x', 'u', 'b', 'a'} {} set() 6. What is the result of this statement: {1, 2, 3, 4, 5} - {3, 4} ^ {5, 6, 7} {1, 2, 6, 7} set() {1, 2} {3, 4, 5, 6, 7} 7. Consider the following expression involving two sets x and y: (x & y = x) and (x & y = y) This expression is True for any sets x and y—true or false? False True 8. What is the result of the highlighted expression: x = {1, 2, 3} y = {1, 2} persubset(x) It raises an exception. set() True False 9. Suppose a set s is defined as follows: s = {'foo', 'bar', 'baz', 'qux'} Which of the following remove element 'bar' from s: s -= {'bar'} s &= {'foo', 'baz', 'qux'} rd('bar') () del s['bar'] rence_update({'bar'}) 10. Which of the following are true about frozen sets: A frozen set can be a member of a set, and can serve as a dictionary key. If f is a frozen set, the statement f |= {'foo'} will raise an exception. You can define a frozen set with this syntax: f = f{'a', 'b', 'c'} If f is a frozen set, the statement ('foo') will raise an exception. 11. s = 'foo' t = 'bar' print('barf' in 2 * (s + t)) What is the output of the print() function call? True False


Document information

Uploaded on
November 25, 2021
Number of pages
15
Written in
2021/2022
Type
Exam (elaborations)
Contains
Questions & answers
$3.79

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
LOVELY01
3.6
(127)
Sold
1015
Followers
881
Items
2321
Last sold
4 months ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these revision notes.

Didn't get what you expected? Choose another document

No problem! You can straightaway pick a different document that better suits what you're after.

Pay as you like, start learning straight away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and smashed it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions

Whoops! We can’t load your doc right now. Try again or contact support.