Social Sciences, asked by mandalsuraj8710, 8 months ago

write a program to input 10 numbers in a list find the greatest and second greatest number​

Answers

Answered by mohammaddayan649
3

Answer:

a(n-2)

Explanation:

Here is source code of the Python Program to find the second largest number in a list. The program output is also shown below.

a=[]

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

for i in range(1,n+1):

b=int(input("Enter element:"))

a.append(b)

a.sort()

print("Second largest element is:",a[n-2])

Program Explanation

1. User must enter the number of elements and store it in a variable.

2. User must then enter the elements of the list one by one using a for loop and store it in a list.

3. The list should then be sorted.

4. Then the last element of the list is printed which is also the largest element of the list.

Similar questions