1.

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

Answer» <html><body><p>a(n-2) Explanation:Here is source code of the Python <a href="https://interviewquestions.tuteehub.com/tag/program-1168801" style="font-weight:bold;" target="_blank" title="Click to know more about PROGRAM">PROGRAM</a> to find the <a href="https://interviewquestions.tuteehub.com/tag/second-1197322" style="font-weight:bold;" target="_blank" title="Click to know more about SECOND">SECOND</a> largest number in a list. The program output is also shown below.a=[]n=int(input("Enter number of elements:"))for i in <a href="https://interviewquestions.tuteehub.com/tag/range-1177030" style="font-weight:bold;" target="_blank" title="Click to know more about RANGE">RANGE</a>(<a href="https://interviewquestions.tuteehub.com/tag/1-256655" style="font-weight:bold;" target="_blank" title="Click to know more about 1">1</a>,n+1): b=int(input("Enter element:")) a.append(b)a.sort()print("Second largest element is:",a[n-2])Program Explanation1. 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 <a href="https://interviewquestions.tuteehub.com/tag/loop-1079198" style="font-weight:bold;" target="_blank" title="Click to know more about LOOP">LOOP</a> 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.</p></body></html>


Discussion

No Comment Found