CBSE Class 11 Computer Science
Question 34 of 39
Tuples and Dictionary — Question 35
Back to all questions 35
Question 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.
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))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
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