Python List
Q1. Find the Product.
Write a program that takes an list as input from the user and find out the product of the elements.
Note: You have to complete Find_Prod. No need to take any input.
Input Format
The input contains a single number N, followed by N numbers as list elements.
Output Format
Return the required answer.
Constraints
1≤N≤201≤ElementoftheList≤100 Example
Sample Input
12345
Sample Output
120
Q2. Find the Sum.
Write a program which takes a list as input from the user and find out the sum of the list elements.
Note: You have to complete Find_Sum. No need to take any input.
Input Format
The input contains a single number N, followed by N numbers as list elements.
Output Format
Return the required answer.
Constraints
1≤N≤1001≤ElementoftheList≤1000
Note: You have to complete Find_Sum function. No need to take any input.
Example
Sample Input
512345
Sample Output
15
Q3. Count Occurrences
You are given an list A containing N integer elements and an integer K, and your task is to return the count of occurrences
of K in list A.
Note: You have to complete findCount function. No need to take any input.
Input Format
The first line of the input contains two space-separated integers N and K, denoting the number of elements in the list A and the
element whose count needs to be determined, respectively. The second line of the input contains N space-separated integers, denoting the
elements of the list A.
Output Format
Return the count of occurrences of K in list A.
Constraints
1≤N≤1001≤K≤1001≤Ai≤1000≤100
Example
Sample Input
33312
Sample Output
2
Q4. Even Odd
You are given an list A containing N integer elements, and your task is to return an list B ((having a size equal to 22)), where B[0]
contains the sum of all even elements of list A and B[1] has the sum of all odd elements of the list A.
Note: You have to complete findEvenOdd function. No need to take any input.
Input Format
The first line of the input contains an integer N, denoting the number of elements in the list A. The second line of the input contains N space-
separated integers, denoting the elements of list A.
Output Format
Return list B as output.
Constraints
1≤N≤1001≤100 0≤Ai≤1000≤100
Example
Sample Input
1234567
Sample Output
12 16
Q5. Find whether the number is present or not
Write a program which takes a list as input from the user and a number. Check whether the number is present or not.
Note: You have to complete Find_Num. No need to take any input.
Input Format
The first line contains an integer N, denoting the size of the list. The second line contains N space-separated integers, denoting the
elements of the list. The third line contains an integer M, denoting the element that needs to be searched.
Output Format
Return the "YES" (without quotes) else return "NO" (without quotes).
Constraints
1≤N≤1001≤ElementoftheList≤1000
Example
Sample Input
123452
Sample Output
YES
Q6. Higher Age
You are given a list A containing the age of persons in your locality, and your task is to find and return an list containing the age of
persons that are over 1818 (18(18 included)).
Note: Also, in the output list, the age should be in the same order as in the input list. You have to complete highAge function. No need
to take any input.
Input Format
The first line of the input contains an integer N, denoting the number of person in your locality. The second line of the input contains
N space-separated integers, denoting the age of persons in your locality.
Output Format
Return the list containing the age of persons that are over 1818 (18(18 included)).
Constraints
1≤N≤1001≤100 0≤Ai≤1000≤100
Example
Sample Input
11 23 3 45 72 68
Sample Output
23 45 72 68
Q7. Increment the List Elements
You are provided the list of integers and you have to increment all list elements by 1 and then print whole list. You have to
complete Inc_Arr. No need to take any input.
Input Format
The input contains a single number N, then N list elements as input.
Output Format
Print the required answer in the function itself.
Constraints
1≤N≤1001≤ElementoftheList≤1000
Example
Sample Input
12345
Sample Output
23456
Q8. Pass or Fail
You are given a list A containing the maths marks of students in your class, and your task is to determine if all the students pass in
your class or not. A student is declared pass if his maths marks are greater than or equal to 3232.
If all the students pass in your class, return "YES" (without quotes); otherwise, return "NO" (without quotes).
Note: You have to complete isAllPass function. No need to take any input.
Input Format
The first line of the input contains an integer N, denoting the number of students in your class. The second line of the input contains N
space-separated integers, denoting the maths marks of students in your class.
Output Format
Return "YES" (without quotes) if all the students pass in your class; other wise, print "NO" (without quotes).
Constraints
1≤N≤1001≤100 0≤Ai≤1000≤100
Example
Sample Input
13 89 45 98 67 45 54
Sample Output
NO
Q9. Unique Color Shirt
Prepbuddy is very tasteful of clothes. He has N numbers of shirts hanging in the hanger in his wardrobe. Prepbuddy likes to wear
different colored clothes. So, whenever he see there are two or more shirts with the same color, he removes all the shir t of that color from
his wardrobe. Now, he wants to know how many M unique color shirts are left in the wardrobe. Prepbuddy wants you to find M.
Note: As there are many shades of a color so consider integers as a color name. i.e, color of shirt is 0,1,2, … , N.
Input Format
The first line of the input contains an integer N denoting the number of shirts in the wardrobe. The second line of the input contains N
integers C1,C2,C3,C4,...,CN1,2,3,4,..., color of shirts (separated by space).
Output Format
Return a single integer M denoting the unique colored shirts left in the wardrobe.
Constraints
1<=N<=1031<=103 1<=C[i]<=1031<=[]<=103
Example
Input
324123
Output
2
Sample test case explanation
Input: C=
Output: 2
There are two 2-color shirts, and two 3-color shirts. So, after removing 2-color and 3-color shirts, the remaining shirts are one 4-color shirt
and one 1-color shirt i.e, .
Hence, the output will be 2.
Q10. Min and Max
Congratulations on making up to this question. Let us give you a fairly simple list problem to solve. If you know how to iterate
through the list, you will easily be able to solve this. The problem statement is simple - given N elements, find the minimum and maximum
numbers among those elements.
Input format
First-line contains N representing the length of the list. The second line contains N space-separated integers.
Output format
Return minimum and maximum elements.
Constraints
1<=N<1071<=<107 0<=A[i]<=1070<=[]<=107
Example
Input
6314627
Output
17
Sample Test Case Explanation
In the first test case minimum element = 1 and maximum element = 7
In the second test case minimum element = 0 and maximum element = 0