Computer Science
If tup = (20, 30, 40, 50), which of the following is incorrect?
- print (tup[3])
- tup[2] = 56
- print (max(tup))
- print (len(tup))
Python Tuples
3 Likes
Answer
tup[2] = 56
Reason — Tuples in Python are immutable. Therefore, attempting to assign a new value to an existing element, such as tup[2] = 56, will result in an error.
Answered By
3 Likes
Related Questions
We cannot delete a dictionary once created.
Which of the statement(s) is/are correct?
- Python Dictionary is an unordered collection of items.
- Python Dictionary is a mapping of unique keys to values.
- Dictionary is mutable.
- All of these
Consider two tuples given below:
tup1 = (1, 2, 4, 3) tup2 = (1, 2, 3, 4)What will the following statement print:
print (tup1 < tup2)- True
- False
- Error
- None of these
Which function returns the number of elements in the tuple?
- len()
- max()
- min()
- count()