KnowledgeBoat Logo

Computer Science

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

Python

Python Control Flow

44 Likes

Answer

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

Answered By

17 Likes


Related Questions