Computer Science
Write a program to display the maximum and minimum values from the specified range of indexes of list.
Python
Python List Manipulation
33 Likes
Answer
l = eval(input("Enter the list: "))
start = int(input("Enter start index: "))
stop = int(input("Enter stop index: "))
slice = l[start : stop + 1]
mx = max(slice)
mi = min(slice)
print("Maximum =", mx)
print("Minimum =", mi)
Output
Enter the list: [89, 42, 12, 56, 35, 2, 8, 7, 13, 69]
Enter start index: 3
Enter stop index: 8
Maximum = 56
Minimum = 2
Answered By
18 Likes
Related Questions
Write programs as per following specifications:
'''L is a list of numbers. Print a new list where each element is the corresponding element of list L summed with number num.'''
Write a program to read two lists num and denum which contain the numerators and denominators of same fractions at the respective indexes. Then display the smallest fraction along with its index.
Write a program to move all duplicate values in a list to the end of the list.
Write a program to compare two equal sized lists and print the first index where they differ.