Page 6 - IPP-11
P. 6
QUESTION 3
(a) Draw a flow chart to check whether a given number is odd or even. (3)
Or
Draw the decision tree to check if a person is eligible for voting (above 18 years of age).
Ans.
Start
Input Number
If
Number % 2 = = 0
Yes No
Display Display
“Even Number” Start “Odd Number”
End
Or
Whether attained
age of 18
Yes No
Not eligible for
Eligible for voting
voting
(b) Write a Python program to find the largest and smallest sum of the elements and mean of the contents
of a list of numbers. (4)
Or
Write a Python program to find the frequency of elements in a list using a dictionary.
E.g.: For the list
['apple','banana','apple','grapes','banana','guava']
the output should be
{'apple': 2, 'banana': 2, 'grapes': 1, 'guava': 1}
Ans. lst= [2,3,4,5]
large = max(lst)
small = min(lst)
total = sum(lst)
mean = sum(lst)/len(lst)
print(large, small, total, mean)
Or
fruits =['apple','banana','apple','grapes','banana','guava']
d = {x:fruits.count(x) for x in fruits}
print(d)
3