Tuples & sets
Tuples are ordered collections whose items cannot be reassigned. Sets keep unique items and do not guarantee an iteration order. Use a set to remove duplicates or test membership.
हिन्दी में समझें
टपल क्रम में मान रखता है, जिनका असाइनमेंट नहीं बदल सकता। सेट में दोहराव नहीं रहता और क्रम की गारंटी नहीं है। सेट से दोहराव हटाएँ।
अभ्यास: unique में 4 जोड़ें ताकि चार अनोखे मान हों।
Hinglish mein samjhein
Tuple ordered hota hai aur items reassign nahi kar sakte. Set unique items rakhta hai, order guaranteed nahi. Duplicates hatane ke liye set useful hai.
Practice: unique mein 4 jodo taaki four unique items hon.
A small Python example
point = (3, 4)
unique = set([1, 1, 2, 3])
print(point[0])
print(len(unique))The browser playground runs real Python with Pyodide. Use sample variables instead of interactive input(). Browser package support differs from desktop Python.
Try this example in the Python playground →Practise this idea
Include 4 in unique so there are four unique items.
Check answer & explanation
point = (3, 4)
unique = set([1, 1, 2, 3, 4])
print(point[0])
print(len(unique))A set removes duplicates, not distinct values. Adding 4 leaves the four unique values 1, 2, 3 and 4.
Stuck in the course? Choose Check answer for either the challenge or quiz. Read the explanation and continue to the next lesson at your own pace.
Check your understanding
How many unique items remain?
Check the quiz answer
3
The duplicate 1 is removed, leaving 1, 2 and 3.
References & corrections
Use the official Python documentation for full language rules. Read how these lessons are made and checked. Found a mistake? Report it to Excel Keys with this lesson URL and a reproducible example.