Computer Science, asked by vishwamdave0305, 5 months ago

Write a program in Python to create a list of n elements and display the minimum element along with its index class 11 CBSE IP​

Answers

Answered by poojan
4

Python program to create a list of n elements and display the minimum element along with its index.

[For execution, check the ATTACHMENTS given below]

Language used: Python Programming

Program:

#Dynamic Program

print("====Dynamic Program====")

list_of_elements=[]

no_of_elements_needed=int(input("Enter the number of elements n: "))

for i in range(no_of_elements_needed):

   list_of_elements.append(float(input("Enter a number: ")))

   #don't preceed any number with 0. decimals are allowed

minimum_element = min(list_of_elements)

print("{0} is the minimum element and its index is {1}".format(minimum_element, list_of_elements.index(minimum_element)))

Output:

====Dynamic Program====

Enter the number of elements: 7

Enter a number: 22

Enter a number: 42.1

Enter a number: 2.5

Enter a number: 7.9

Enter a number: 35

Enter a number: 257

Enter a number: 98

2.5 is the minimum element and its index is 2

#Static Program

print("====Static Program====")

list_of_elements = [7,35,98,34,3,54]

minimum_element = min(list_of_elements)

print("{0} is the minimum element and its index is {1}".format(minimum_element, list_of_elements.index(minimum_element)))

Output:

====Static Program====

3 is the minimum element and its index is 4

Note:

  • min(list_name) gives the minimum value present in the list.
  • list_name.index(value) gives the index of that value in the list.
  • Follow Indentation.

Learn more:

1) Printing all the palindromes formed by a palindrome word.

brainly.in/question/19151384

2) Indentation is must in python. Know more about it at :

brainly.in/question/17731168

3) Write a Python function sumsquare(l) that takes a nonempty list of integers and returns a list [odd,even], where odd is the sum of squares all the odd numbers in l and even is the sum of squares of all the even numbers in l.

brainly.in/question/15473120

4) Python program to find absolute difference between the odd and even numbers in the inputted number.

brainly.in/question/11611140

Attachments:
Similar questions