Program to find minimum element from a list in Python Class XI, XIl CBSE

 Program to find minimum element from a list of element along with its index in the list

The Python lists are containers that are used to store a list of values of any type. Unlike other variables Python lists are mutable i.e., you can change the elements of a list in place: Python will not create a fresh list when you make changes to an element of a list. List is a type of sequence like strings and tuples but it differs from them in the way that lists are mutable but strings and tuples are immutable.


Program to find minimum element from a list

1st eval(input("Enter list: "))

length len(1st)

min_ele = lst[0]

min_index = 0

for i in range(1, length) : 

        if lst[i]< min_ele :

        min_ele 1st[i]

        min_index = i

print("Given list is : ", 1st) 

print("The minimum element of the given list is :")

print(min_ele, "at index", min_index)


Output 

Enter list : [2, 3, 4, -2, 6, 7, 8, 11, 9, 11]

Given list is [2, 3, 4, -2, 6, 7, 8, 11, 9, 11]

The minimum element of the given list is :

-9 at index 8

Post a Comment

If you any doubts, Please let me know

Previous Post Next Post