Computer Science, asked by rahulKumara4228, 9 months ago

Write a program to input names of n students and store them in a tuple. Also, input a name from the
user and find if this student is present in the tuple or not. We can accomplish these by:
(a) writing a user defined function
(b) using the built-in function

Answers

Answered by Anonymous
4

Answer:

. The 'index()' function returns the index of the first occurrence of the element in a tuple.

OUTPUT:

2

ii. The 'count()' function returns the numbers of times the given element appears in the tuple.

OUTPUT:

3

iii. '+' operator concatenate the two tuples.

OUTPUT:

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

iv. The 'len()' function returns the number of elements in the given tuple.

OUTPUT:

2

v. The 'max()' function returns the largest element of the tuple.

OUTPUT:

67

vi. The 'min()' function returns the smallest element of the tuple.

OUTPUT:

1

vii. The 'sum()' function returns the sum of all the elements of the tuple.

OUTPUT:

300

viii. The 'sorted()' function takes element in the tuple and return a new sorted list. It doesn’t make any changes to the original tuple. Hence, print(tuple1) will print the original tuple1 i.e. (23, 1, 45, 67, 45, 9, 55, 45)

OUTPUT:

[1, 9, 23, 45, 45, 45, 55, 67]

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

Similar questions