Consider the following tuples, tuple1 and tuple2: tuple1 = (23,1,45,67,45,9,55,45) tuple2 = (100,200) Find the output of the following statements:
print(tuple1.index(45))
2
print(tuple1.count(45))
3
print(tuple1 + tuple2)
(23, 1, 45, 67, 45, 9, 55, 45, 100, 200)
print(len(tuple2))
2
print(max(tuple1))
67
print(min(tuple1))
1
print(sum(tuple2))
300
print(sorted(tuple1)) print(tuple1)
[1, 9, 23, 45, 45, 45, 55, 67] (23, 1, 45, 67, 45, 9, 55, 45)
Explanation
This question tests understanding of built-in tuple functions and operations. The index() method returns the first occurrence position of an element. The count() method returns the total occurrences of an element. Concatenation using + joins two tuples. The len() function returns the number of elements. The max() and min() functions return the largest and smallest elements respectively. The sum() function returns the total of all numeric elements. The sorted() function returns a sorted list without modifying the original tuple.