You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _sources/functions/funcWithSetsAndDict.rst
+34-5Lines changed: 34 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -256,7 +256,7 @@ You can use the following methods with sets.
256
256
.. fillintheblank:: funct_exor_fitb
257
257
:practice: T
258
258
259
-
What character is used to find the symmetric difference between two sets in the code above?
259
+
What character is used to find the symmetric difference (exlusive or) between two sets in the code above?
260
260
261
261
- :\^: Use a ^ to indicate the symmetric difference between two sets (exclusive or)
262
262
:.*: Which gives the same output as the symmetric_difference method?
@@ -266,10 +266,9 @@ You can use the following methods with sets.
266
266
:feedback: Read this page and try again.
267
267
:match_1: &||| intersection
268
268
:match_2: <=||| issubset
269
-
:match_3:\|||| union
270
-
:match_4: >=||| issuperset
271
-
:match_5:\-||| difference
272
-
:match_6:\^||| symmetric_difference
269
+
:match_3: >=||| issuperset
270
+
:match_4: -||| difference
271
+
:match_5: ^||| symmetric_difference
273
272
274
273
Drag each symbol to the method it is equivalent to.
275
274
@@ -319,6 +318,36 @@ Sorting Sets
319
318
.. Note::
320
319
321
320
The function sorted(set) will return a new sorted list in ascending order.
321
+
322
+
.. parsonsprob:: func_set_unique_characters_pp
323
+
:numbered: left
324
+
:adaptive:
325
+
:practice: T
326
+
327
+
Drag the blocks from the left and put them in the correct order on the right to define a function ``total_even`` that returns the total of the even numbers in the passed list.
328
+
-----
329
+
def unique_characters(strings):
330
+
=====
331
+
# Initialize an empty set to store unique characters
332
+
unique_chars = set()
333
+
=====
334
+
# Iterate over each string in the list
335
+
for string in strings:
336
+
=====
337
+
# Add all characters of the current string to the set
338
+
unique_chars.update(string)
339
+
=====
340
+
# Add all characters of the current string to the set
0 commit comments