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
Write a program rotates the elements of a list so that the element at the first index moves to the second index, the element in the second index moves to the third index, etc., and the element in the last index moves to the first index.
A list Num contains the following elements:
3, 25, 13, 6, 35, 8, 14, 45
Write a program to swap the content with the next value divisible by 5 so that the resultant list will look like:
25, 3, 13, 35, 6, 8, 45, 14
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.