Lesson 5
Tuples & Sets
Other data collections
1What Are Tuples?✨
Tuples are a collection of items that are ordered and unchangeable. They can hold different data types and are defined using parentheses.
2Example:🎯
my_tuple = (1, "apple", 3.14)
print(my_tuple)3What Are Sets?💡
Sets are collections of unique items that are unordered. They are useful when you want to store items without duplicates. Sets are defined using curly braces.
4Example:🚀
my_set = {1, 2, 3, 2}
print(my_set)5Creating Tuples🔍
You can create a tuple with a mix of data types. Tuples are great for storing related data.
6Example:⭐
person = ("John", 25, "Engineer")
print(person)7Accessing Tuple Elements🧩
You can access elements in a tuple using indexing, just like with lists. Remember, indexing starts at 0!
8Example:🎈
print(person[1]) # Outputs: 259Working with Sets✨
Sets have unique properties. You can add or remove items easily.
10Example:🎯
my_set.add(4)
print(my_set) # Outputs: {1, 2, 3, 4}11Benefits of Tuples and Sets💡
- ✓ Tuples are useful for fixed collections of data
- ✓ Sets are perfect for avoiding duplicates
- ✓ Both are efficient and fast for data operations
- ✓ Great tools for organizing your data!
🎯 Practice Challenges
Master Tuples & Sets by completing all 3 difficulty levels
Tuples & Sets - Easy Challenge
Start with the basics. Perfect for beginners!
Tuples & Sets - Medium Challenge
Get more challenging. Build your confidence!
Tuples & Sets - Hard Challenge
Master this concept. Prove your skills!
🏆 Study a lesson for 2+ minutes to earn +10 TalentJR Points a day. Badges, certificates & prizes →
Ready to Master Tuples & Sets? 🚀
Complete the challenges, take the quiz and keep your learning streak going!
Keep learning
- ← Previous lessonLesson 4: DictionariesKey-value data storage
- Next lesson →Lesson 6: Data ProjectsBuild data-driven programs
- Grade 8 courseJavaScript Basics - Web ProgrammingJavaScript coding course for kids.
- Student ToolsFree calculators for studentsPercentage, fraction, ratio and marks calculators with steps.
- CBSEClass 7 CBSE & NCERT study materialMaths, Science and Computer chapters with solutions.
- Future SkillsExplore future skillsAI, robotics and new-age skills explained for students.