Input 10 numbers and print the largest using for loop in Python
for Loop - Question 8
In this question, we will see how to input 10 numbers and print the largest number among them in Python programming using for loop. To know more about for loop click on the for loop lesson.
Q8) Write a program in Python to input 10 numbers and print the largest number among them using for loop.
lar=0 print('Enter 10 numbers') for i in range(1,11): n=int(input()) if i==1: lar=n # store the first number elif n>lar: # compare the previous stored number with the latest entered number lar=n print('Largest Number = %d' %(lar))
Enter 10 numbers 15 3 6 9 84 21 34 59 5 12 Largest Number = 84