Wednesday 14 February 2024

Class 11 CS Practical - 33

 

33 - Write a program in Python to Input a list of numbers and find the largest number in a list. 


L=[]

c='y'

while c=='y' or c=='Y':

    a=int(input("Enter an integer number to append in the list: "))

    L.append(a)

    c=input("Do you want to add more elements in the list (Y/N): ")

print("List is: \n", L)

print("Maximum(Largest) number of the list = ",max(L))


Output:

Enter an integer number to append in the list: 5

Do you want to add more elements in the list (Y/N): y

Enter an integer number to append in the list: 8

Do you want to add more elements in the list (Y/N): y

Enter an integer number to append in the list: 2

Do you want to add more elements in the list (Y/N): y

Enter an integer number to append in the list: 9

Do you want to add more elements in the list (Y/N): y

Enter an integer number to append in the list: 4

Do you want to add more elements in the list (Y/N): n

List is: 

 [5, 8, 2, 9, 4]

Maximum(Largest) number of the list =  9

No comments:

Post a Comment