22CS1ESPYP (4)
22CS1ESPYP (4)
Instructions: 1. Answer any FIVE full questions, choosing one full question from each unit.
2. Missing data, if any, may be suitably assumed.
UNIT - I
Important Note: Completing your answers, compulsorily draw diagonal cross lines on the remaining blank
UNIT - III
3 a) Illustrate with an example function call and passing arguments to a function in 6
Python.
b) Demonstrate with an example the advantages of sequence packing and 6
unpacking of tuples.
c) Write a Python program for the following scenario: 8
Given an array of names of candidates in an election. A candidate name in the
array represents a vote cast to the candidate. Print the name of candidates
received Max vote. If there is tie, print a lexicographically smaller name.
OR
4 a) Given a list of elements, perform grouping of similar elements, as different 6
key-value list in dictionary.
Sample Input : test_list = [4, 6, 6, 4, 2, 2, 4, 8, 5, 8]
Output : {4: [4, 4, 4], 6: [6, 6], 2: [2, 2], 8: [8, 8], 5: [5]}
b) Analyse the following code and write the output with suitable justification: 6
def Merge(dict1, dict2):
return(dict2.update(dict1))
UNIT - V
7 a) Suppose we have created a file with 500 lines of data and the the file object 5
reference is “f”.
Illustrate what each of these following operations does:
(i) F.seek(0)
(ii) F.seek(100,1)
(iii) F.seek(-10,2)
(iv) F.seek(0,2)
(v) F.tell()
d) Write a program that will calculate the average word length of a text stored in 5
a file (i.e the sum of all the lengths of the word tokens in the text, divided by
the number of word tokens).
******