KnowledgeBoat Logo

Computer Science

Write a program to accept values from a user in a tuple. Add a tuple to it and display its elements one by one. Also display its maximum and minimum value.

Python

Python Tuples

6 Likes

Answer

tuple1 = eval(input("Enter a tuple: "))
tuple2 = (10, 20, 30)
combined_tuple = tuple1 + tuple2
print("Elements of the combined tuple:")
for element in combined_tuple:
    print(element)

print("Maximum value:", max(combined_tuple))
print("Minimum value:", min(combined_tuple))

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

Answered By

3 Likes


Related Questions