Skip to content

Commit d150d6f

Browse files
committed
fixes and new PP
1 parent c74de53 commit d150d6f

1 file changed

Lines changed: 34 additions & 5 deletions

File tree

_sources/functions/funcWithSetsAndDict.rst

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ You can use the following methods with sets.
256256
.. fillintheblank:: funct_exor_fitb
257257
:practice: T
258258

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?
260260

261261
- :\^: Use a ^ to indicate the symmetric difference between two sets (exclusive or)
262262
:.*: Which gives the same output as the symmetric_difference method?
@@ -266,10 +266,9 @@ You can use the following methods with sets.
266266
:feedback: Read this page and try again.
267267
:match_1: &||| intersection
268268
: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
273272

274273
Drag each symbol to the method it is equivalent to.
275274

@@ -319,6 +318,36 @@ Sorting Sets
319318
.. Note::
320319

321320
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
341+
unique_chars.add(string) #paired
342+
=====
343+
# Convert the set to a sorted list
344+
sorted_unique_chars = sorted(unique_chars)
345+
=====
346+
# Convert the set to a sorted list
347+
sorted_unique_chars = sort(unique_chars) #paired
348+
=====
349+
# reurn the sorted list of unique characters
350+
return sorted_unique_chars
322351

323352

324353
Dictionaries

0 commit comments

Comments
 (0)