Tuple creation
๐ Scenario: You are organizing a small fruit basket for a friend. You want to keep the list of fruits in a fixed order so it doesn't change accidentally.
๐ฏ Goal: Create a tuple with the exact fruits, then display it.
๐ What You'll Learn
Create a tuple called
fruits with these exact items in order: 'apple', 'banana', 'cherry'Create a variable called
count that stores the number of fruits in the tupleUse a
for loop with variable fruit to iterate over fruitsPrint each fruit on its own line
Print the total count of fruits at the end
๐ก Why This Matters
๐ Real World
Tuples are useful when you want to store a list of items that should not change, like days of the week or fixed settings.
๐ผ Career
Understanding tuples helps in data handling and writing safer code where data should remain constant.
Progress0 / 4 steps