Question 1 of 14intermediate🔧 ApplyShort Answer4 marks

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:

(i)

print(tuple1.index(45))

Answer

2

(ii)

print(tuple1.count(45))

Answer

3

(iii)

print(tuple1 + tuple2)

Answer

(23, 1, 45, 67, 45, 9, 55, 45, 100, 200)

(iv)

print(len(tuple2))

Answer

2

(v)

print(max(tuple1))

Answer

67

(vi)

print(min(tuple1))

Answer

1

(vii)

print(sum(tuple2))

Answer

300

(viii)

print(sorted(tuple1)) print(tuple1)

Answer

[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.