Computer Science
WAP to accept values from a user. Add a tuple to it and display its elements one by one. Also display its maximum and minimum value.
Answer
t1 = eval(input("Enter a tuple: "))
t2 = (10, 20, 30)
t3 = t1 + t2
print("Elements of the combined tuple:")
for element in t3:
print(element)
print("Maximum value:", max(t3))
print("Minimum value:", min(t3))Output
Enter a tuple: (11, 67, 34, 65, 22)
Elements of the combined tuple:
11
67
34
65
22
10
20
30
Maximum value: 67
Minimum value: 10
Related Questions
Write the output of the following statements:
(a) >>> tuple([10,20,40])
(b) >>> ("Tea",)*5
(c) >>> tuple ("Item")
Consider two tuples t1 & t2 given below:
t1 = (100, 200, 300) t2 = (10, 20, 30, 40)Write the output of the following statements:
(a)
t1, t2 = t2, t1 print(t1) print (t2)(b)
print (t1!=t2)(c)
print (t1 < t2)Write a program to input any values for two tuples. Print it, interchange it and then compare them.
Write a Python program to input 'n' classes and names of class teachers to store them in a dictionary and display the same. Also accept a particular class from the user and display the name of the class teacher of that class.