Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE
Chembur, Mumbai - 400 088
UG Program in Electronics and Computer Science
Academic Year: 2024-2025
Experiment No: 03
Aim: Study of tuple and dictionaries in python
Problem Statement:
1. Create three lists- a lists of names, a list of age, a list of salaries.
2. Generate and print a list of tuples containing name, age and salaries from
3 lists.
3. From this list generate 3 tuples one contains all age, one contains all
names, one contains all the salaries.
Theory:
Tuple is the collection of the object much like the lists. The sequence is s of value stored in the
tuple can be any type, and they are indexed by integers. Value of tuple are syntactically separated
by ‘commas. Although it is not necessary, it is more effective way to define tuple. Sequence of
the parenthesis. This help tuple to understand more easily. It is defined within parentheses ()
where items are separated by commas. >>> t = (5,'program', 1+3j) We can use the slicing
operator [] to extract items but we cannot change its Value.
Dictionaries: Dictionaries are used to store data values in key:value pairs. A dictionary is a
collection which is ordered*, changeable and does not allow duplicates.
Example:
thisdict={ "Food_category
": "fruit", "seasonal":
"Mango",
"month": "April"
}
print(thisdict["Food_category"])
Program:
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE
Chembur, Mumbai - 400 088
UG Program in Electronics and Computer Science
Academic Year: 2024-2025
1:
2:
3:
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE
Chembur, Mumbai - 400 088
UG Program in Electronics and Computer Science
Academic Year: 2024-2025
Out Put:
3:
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE
Chembur, Mumbai - 400 088
UG Program in Electronics and Computer Science
Academic Year: 2024-2025