Take 10 integer inputs from user and store them in a list. Again ask user to give a number. Now, tell user whether that number is present in list or not. ( Iterate over list using while loop ).
i=10a=[]whilei>0:print"Enter number"num=input()a.append(num)i=i-1print"Enter a number"n=input()i=9count=0whilei>=0:ifn==a[i]:print"Yes"count=count+1i=i-1ifcount==0:print"No"#python way, without loopifnina:print"Yes"else:print"No"
3.
Take 20 integer inputs from user and print the following: number of positive numbers number of negative numbers number of odd numbers number of even numbers number of 0s.
Take 10 integer inputs from user and store them in a list. Now, copy all the elements in another list but in reverse order.
i=10a=[]whilei>0:print"Enter number"num=input()a.append(num)i=i-1# reverse elements of aa.reverse()#copied to new listb=a#again back to initial ordera.reverse()
5.
Write a program to find the sum of all elements of a list.
6.
Write a program to find the product of all elements of a list.
7.
Initialize and print each element in new line of a list inside list.
Ask user to give integer inputs to make a list. Store only even values given and print the list.
#Hintifnum%2==0:a.append(num)
Level 2
1.
Take a list of length n where all the numbers are non-negative and unique. Find the element in the list possessing the highest value. Split the element into two parts where first part contains the next highest value in the list and second
part hold the required additive entity to get the highest value. Print the list where the highest value get splitted into those two parts.
Sample input: 4 8 6 3 2
Sample output: 4 6 2 6 3 2