Basics of Python-6

Hello, I'm Priya Chakraborty, a dedicated B.Tech student in Electrical Engineering at Siliguri Institute Of Technology. I'm an enthusiastic learner, constantly seeking to expand my skill set and knowledge base. With a solid foundation in programming languages such as C, R, Python, and MySQL, I'm poised to tackle complex technical challenges.
But my passions extend beyond the realm of engineering. I'm also an aspiring content writer, driven by a curiosity to communicate ideas, both technical and non-technical, in a way that captivates and educates.
My journey is defined by a relentless pursuit of self-improvement, coupled with strong communication skills. I believe in the power of continuous learning and the importance of sharing knowledge.
Day 6
Tuple :
Tuple is an in-built data type in python and is used to collect objects, by separation of commas.
Tuples are mutable.
We use the '( )' operator to denote a tuple
Indexing is the same as the list
Let's solve a few problems on tuples:
- Find the maximum and minimum element in the tuple :
n=(1,5,3,2,0)
print(sorted(n))
print(max(n))
print(min(n))
output:

- To find the sum of the tuple element:
n=(7,9,3,4)
sum=0
for i in n:
sum=sum+i
print(sum)
output:

Problems :
Write a python program to find Row-wise element Addition in Tuple MatrixWrite a python program to update each element in the tuple listWrite a python program to multiply Adjacent elementsWrite a python program to join Tuples if the similar initial elementWrite a python program to find All pair combinations of 2 tuplesWrite a python program to remove Tuples of Length KWrite a python program to remove Tuples from the List having every element as NoneWrite a python program to sort a list of tuples by the second ItemWrite a python program to sort Tuples by Total digitsWrite a python program to find Elements frequency in TupleWrite a python program to filter Range Length TuplesWrite a python program to assign Frequency to TuplesWrite a python program to find Records with Value at the K index
Let's have a look at the basic difference between list and tuple :
| LIST | TUPLE |
| we use '[ ]' operator | we use '( )' operator |
| List is mutable | Tuple is immutable |
In my next blog, you will get to about set data types.
Thank you!




