Question: 1 . ( 1 1 points: 1 point each ) The following are true / false questions. Write either T or F in the boxes

1.(11 points: 1 point each) The following are true/false questions. Write either T
or F in the boxes at the bottom of page 1. If theres any counterexample, its
false.
(a) If a list in Python contains multiple identical items and you try to convert it
to a set, the program will crash.
(b) If you try to access a key that does not exist in a dictionary, Python will return
None.
(c) Using curly braces {} creates an empty set.
(d) The dictionary comprehension {str(x):0 for x in range(1,6)} is equivalent to the dictionary {"1":0,"2":0,"3":0,"4":0,"5":0}.
(e) The "in" operator can be used to check for the presence of an element in a
tuple, but it doesnt work on sets because sets have no order.
(f) The symmetric difference of two sets in Python can also be expressed as the
union of the two sets, minus their intersection.
(g) The .pop() method for dictionaries in Python removes the last added key-value
pair of the dictionary and returns it.
(h) When iterating over a dictionary using a for loop, the loop variable refers to
the keys of the dictionary.
(i) You can loop over sets, but you cannot loop over tuples.
(j) Assuming s1 and s2 are both sets, the expression s1.difference(s2) can
return a different result from s2.difference(s1).
(k) Both lists and tuples in Python support adding elements after creation, but
unlike lists, elements in a tuple cannot be changed once added.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!