Lesson 20 of 34

Sets: അദ്വിതീയ Values മാത്രം

7 min 25 XP

Set ഒരേ value രണ്ടുതവണ സൂക്ഷിക്കില്ല. List-ൽ നിന്ന് duplicates നീക്കാൻ ഏറ്റവും എളുപ്പ വഴി set() ആണ്.

Example: edit me and press Run

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.

രണ്ട് sets താരതമ്യം ചെയ്യൂ: | (union) എല്ലാം, & (intersection) രണ്ടിലും ഉള്ളത്, - (difference) ആദ്യത്തേതിൽ മാത്രമുള്ളത്.

Example: edit me and press Run

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.

Sets-ന് ക്രമമില്ല, അതിനാൽ set[0] പ്രവർത്തിക്കില്ല. ക്രമത്തിൽ വേണമെങ്കിൽ sorted() ഉപയോഗിക്കൂ.

Challenge

+25 XP

nums = [5, 3, 5, 1, 3, 9, 1]. എത്ര അദ്വിതീയ സംഖ്യകളുണ്ടെന്ന് print ചെയ്യൂ, പിന്നെ അടുത്ത വരിയിൽ അവ sorted list ആയി print ചെയ്യൂ.

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.