Dremendo Tag Line

Input 10 numbers in integer list and find largest and the smallest number position in Python

Lists - Question 3

In this question, we will see how to input 10 numbers in integer list and find the position of the largest and the smallest number in Python programming. To know more about lists click on the lists lesson.

Q3) Write a program in Python to input 10 numbers in integer list and find the position of the largest and the smallest number.

Program

ln=0; lnp=0; sn=0; snp=0
a=list()

print('Enter 10 numbers')
for i in range(10):
    a.append(int(input()))

for i in range(10):
    if i==0:
        ln=a[i]
        sn=a[i]
        lnp=i
        snp=i

    elif a[i]>ln:
        ln=a[i]
        lnp=i

    elif a[i]<sn:
        sn=a[i]
        snp=i

print('Largest Number Position = %d' %(lnp+1))
print('Smallest Number Position = %d' %(snp+1))

Output

Enter 10 numbers
63
12
57
61
98
11
3
4
75
82
Largest Number Position = 5
Smallest Number Position = 7
video-poster