Professional Documents
Culture Documents
FortyMarksTest GroupAB
FortyMarksTest GroupAB
General Instructions
1. (Marks: 10) Consider the yearwise Sensex Annual Returns of the Bombay Stock Exchange from 2014
to 2022 as shown in Table 1.
Implement a suitable Interpolation formula to find the Sensex Annual Returns for year 2015.
2. (Marks: 10) A pack of assorted chocolates contains some dark flavored toffees, some white flavored
toffees and some hazelnut flavored toffees. If you multiply the number of dark flavored toffees by 3,
deduct twice the number of white flavored toffees from it and add the number of hazelnut flavored
toffees to it, you get 17. The sum of the number of dark, white and hazelnut toffees is 16. Finally, if you
consider the number of dark flavored toffees, deduct the number of white flavored toffees from it and
add the number of hazelnut flavored toffees to it, you get 6.
Express the above information in terms of numbers of the three types of toffees as the variables and
solve the system of equations using np.linalg.det() to find the number of each type of toffee.
3. (Marks: 10) A man Ravi is imprisoned in a castle. Every day he wakes up and tosses a fair coin and
decides on Heads that he should try to escape, or else he waits for the day. In case he decides to try
an escape, he walks to a point where there are two routes leading to two gates. There he tosses a fair
coin again: on Heads he chooses Gate 1, on Tails chooses Gate 2. At Gate 1, there is a guard who asks
4 questions in order with increasing difficulty level such that the chances for Ravi to answer them are
95%, 90%, 85% and 80% (in this order). At Gate 2, there is another guard who asks 2 questions in
order with increasing difficulty level such that the chances for Ravi to answer them are 70% and 50%
(in this order). Ravi can escape if he is able to answer ALL of the questions for the chosen gate. Use
random() function of python module random to simulate the coin tossing events and uniform() function
of the same module to simulate the question-answering events. Print a message at every stage of decision
making. A sequence of events when Ravi chooses to go for an escape, chooses Gate 1 and successfully
escapes is:
Let’s try today!
Gate 1 chosen!
Answer 0 correct!
Answer 1 correct!
Answer 2 correct!
Answer 3 correct!
Congrats!
4. [TRY IF YOU ARE BRAVE!!]
Consider a query auto-completion system in a search engine. Construct a question bank containing the
list of all the previously searched queries. The question bank may contain queries like “how to dance”,
“how to make coffee”, “how to write c program”, “how to cook”, “how to cook pasta”, “how to write a
formal letter” etc.
(a) (Marks: 4) Take an incomplete query (e.g. “how to write”) as input from the user and print the
queries as suggestion that exactly match (in sequence) the input query. For the example input, the
automatically suggested complete queries should be “how to write c program” and “how to write a
formal letter”.
(b) (Marks: 6) Modify the above system to suggest complete queries even if there is no exact match.
However, only the best suggestions (those with the maximum match) should be displayed. That is,
for the input query “how do I cook”, the suggestions should be:
how to cook
how to cook pasta
5. [TRY IF YOU LIKE TO PLAY SAFE !!]
Consider the Minimum CGPA (for PhD admission) and QS World University Ranking of some universi-
ties/institutes shown in Table 2. The target is to automatically suggest the suitable universities/institutes
for a given student profile.
(a) (Marks: 5) Assume the CGPA-Ranking pairs as points on a 2-dimensional Euclidean space and
on this construct your dataset for clustering. Also plot these points using scatter plot of Matplotlib.
Apply the elbow method of K-means clustering to chose the appropriate value of K (also trust
your eyes!) and using this value finally cluster the data using K-means algorithm implemented in
sklearn into different groups. Plot the output of the elbow method and the final clusters of these
groups using scatter plot of Matplotlib.
(b) (Marks: 5) Now take a Student Name and her/his total Master’s CGPA and QS ranking of the
university/institute where she/he obtained her/his Master’s degree, as input from the user. The
scheme for the recommendation of the suitable universities/institutes to the student works as follows:
the student’s (CGPA, QS ranking) is compared with the points in each cluster; for each cluster the
farthest data point from student’s (CGPA, QS ranking) is identified; among these cluster-wise
farthest data points, the closest one is picked and the cluster of this picked data point gives the
set of suitable universities/institutes for the student. Note that, for K = n, n is a positive integer,
Page 2
University/Institute Name Minimum CGPA (out of 10) QS Ranking
Harvard 9.4 5
MIT 8.5 1
Stanford 8.5 3
Princeton 9.7 16
Ghent 6.0 390
Adeleide 6.5 109
Liverpool 7.5 190
Nagoya 7.5 112
Peking 8.75 12
NTU 8.5 19
Griffith 6.2 300
Stuttgart 6.5 355
the
p clusters are labelled as [0, 1, 2, ..., n-1]) and for two points (x1 , y1 ) and (x2 , y2 ), distance is
(x1 − x2 )2 + (y1 − y2 )2 . Also plot the clusters with the student (in a different colour) on a scatter
plot of Matplotlib. E.g. if the student’s CGPA and QS ranking respectively are 8.5 and 52, then
the recommended universities/institutes will be the likes of Harvard, MIT, Stanford etc.
Page 3