CBSE Class 11 Computer Science Question 138 of 161

Flow of Control — Question 15

Back to all questions
15
Question

Question 15

Write a short program to find largest number of a list of numbers entered through keyboard.

Solution
print("Enter numbers:")
print("(Enter 'q' to see the result)")

l = input()

if l != 'q' and l != 'Q' :
    l = int(l)
    while True:
        n = input()
        if n == 'q' or n == 'Q' :
            break
        n = int(n)
        if n > l :
            l = n
    print("Largest Number =", l)
Output
Enter numbers:
(Enter 'q' to see the result)
3
5
8
2
4
q
Largest Number = 8
Answer