Category: Python

Python – Tuple Methods

1. What are Tuple Methods? Tuple methods are built-in functions that help us work with tuple data. Tuples are read-only, so they have very few methods. 👉 Python tuples have only TWO main methods:...

Python – Tuple Exercises

Exercise 1: Create a Tuple Question Create a tuple of fruits and print it. Solution fruits = (“apple”, “banana”, “orange”) print(fruits) Exercise 2: Access Tuple Items Question Print the first and last item of...

Python Sets

1. What is a Set? A set is a collection of items that is: Unordered No duplicate values Changeable In simple words: 👉 A set stores unique values only. 2. Creating a Set Sets...

Python – Access Set Items

1. What Does “Access Set Items” Mean? Accessing set items means reading values from a set. But remember 👇👉 Sets are unordered, so: No index numbers No position like first or last 2. You...

Python – Add Set Items

1. What Does “Add Set Items” Mean? Adding set items means putting new values into a set. Remember: 👉 Sets store only unique values.👉 Duplicate values are not added. 2. Add One Item to...

Python – Remove Set Items

1. What Does “Remove Set Items” Mean? Removing set items means deleting values from a set. Remember: 👉 A set has no order👉 You cannot remove items using index Python gives us easy methods...

Python – Loop Sets

1. What Does “Loop Sets” Mean? Looping a set means going through each item one by one. Remember: 👉 Sets are unordered👉 You will not get items in fixed order 2. Loop Through Set...

Python – Join Sets

1. What Does “Join Sets” Mean? Joining sets means combining two or more sets. Remember: 👉 Sets store only unique values👉 Duplicate values are removed automatically 2. Join Sets Using union() union() combines all...

Python frozenset

1. What is a frozenset? A frozenset is just like a set, but with one big difference 👇 👉 A frozenset cannot be changed. In simple words: set → changeable frozenset → NOT changeable...

Python – Set Methods

1. What are Set Methods? Set methods are built-in functions that help us work easily with sets. Sets are used to: Store unique values Remove duplicates Do math-like operations (union, intersection) 2. add() –...