Dremendo Tag Line

Input 10 numbers and check all numbers are in ascending order or not using while loop in Python

while Loop - Question 10

In this question, we will see how to input 10 numbers and check if all the entered numbers are in ascending order or not in Python programming using while loop. To know more about while loop click on the while loop lesson.

Q10) Write a program in Python to input 10 numbers and check if all the entered numbers are in ascending order or not using while loop.

Program

i=1; asc=0; lar=0

print('Enter 10 numbers')
while i<=10:
    n=int(input())
    if i==1:
        lar=n       # store the 1st number as largest number
        asc=asc+1

    elif n>lar:
        lar=n
        asc=asc+1

    i=i+1

if asc==10:
    print('All entered numbers are in ascending order')
else:
    print('All entered numbers are not in ascending order')

Output

Enter 10 numbers
2
6
9
15
18
20
23
29
56
74
All entered numbers are in ascending order
video-poster