Sunday, 23 January 2022

Create a list a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] and write a python program that prints out all the elements of the list that are less than 5

Slip 18 Q 1

CODE:


list1 =[]
list3=[]
list2=[]
n=int(input('Enter number of elements : '))
for i in range(n):
    value=int(input())
    list1.append(value)
print(list1)
n=int(input('Enter a number to sort list : '))

for i in list1:
    if n > i:
        list2.append(i)
    else:
        list3.append(i)
print('less then {} value list : '.format(n),list2)
print('greater then {} value list :'.format(n),list3)

OUTPUT:




No comments:

Post a Comment

Write a Java program to display given extension files from a specific directory on server machine.

 DOWNLOAD     SLIP14Q2 /** * STEPS TO RUN CODE * Step 01 compile the code * Step 02 run the code * Step 03 give a file directory locatio...