Professional Documents
Culture Documents
General Instructions:
1. The question paper is divided into 3 Sections - A, B and C.
2. Section A- consist of 15 Questions (1 – 15), Section B- consist of 15 Questions
(16 - 30), Section C- consist of 5 case study based Questions (31 – 35) .
SECTION- A
Q.1 Choose the right option showing right order of precedence from highest to least:
Q.2 As the keys in a dictionary are considered to be unique, given D={‘a’: 100, ‘b’:200,
‘c’:300}, a statement as D[‘c’]= 500 will result in:
[A] KeyError
[C] SyntaxError
[D] No Change
[A] break
[B] pass
[C] continue
[D] None
: Page2 :
[A] if ,else
Q.6 The number of times the asterisk * will be printed in the following code is
for k in range(15,3,-7) :
for j in range(k,0,-1):
print('*')
[A] 15 times
[B] 0 times
[C] 23 times
[D] 24 times
print("Revision_Exam"[: : -1].upper().startswith('M'))
[A] maxE_noisiveR
[B] True
[C] MAXE_NOISIVER
[D] False
A, B, C, D = T
: Page3 :
[A] Assignment
[B] Packing
[C] Unpacking
[D] Initialization
Q.10 Given Lst=[3,10,9,8] which of the following will remove all the elements in the list and
make it an empty list:
[B] Lst[:] = [ ]
Q.11 What will be the result of: tuple({‘a’: 100, 5: ‘b’, “area”: 200 })
[D] ValueError
Q.12 The command to merge a dictionary Book with another dictionary Library is:
[C] Book.extend(Library)
[D] Library.update(Book)
Q.13 What will be the result for: print( "Look before you leap". lower().strip('apollo'))
Q.14 What will be the result for: print("birds of feather flock together". split('r'))
Q.15 What will be the result for : print("Rolling stone gather no moss"[-2:15:-2].title())
[A] Smo et
[C] Smo Et
SECTION - B
Q.16 Assume a package Mensuration exists with a module Area which has a function
Area_Circle. What is the correct form of import statement to access the function directly as
Area_Circle()
[C] Prog(Type='Language')
L1= “exam”
L2= [(L1[k]*(k+1)) for k in range(len(L1))]
print(L2)
L1=[12,45,56,78,90,4,10]
L2=[E**2 for E in L1[-1:2:-2] if (E-len(L1))%3==0]
print(L2)
[B] [ ]
[C] [100]
[D] SyntaxError
numberGames = {}
numberGames[(1,2,4)] = 8
numberGames[(4,2,1)] = 10
numberGames[(3,1)] = 12
sum = 0
for k in numberGames:
[A] 30
[B] 24
[C] 33
[D] 12
: Page6 :
[A] TypeError
[B] P y t h o n
[C] None
[D] Python
[A] IndexError
[B] SyntaxError
[C] No output
Q.23 Given the following statement, what will the print command show?
a , L = None, [ ]
L += [a]
print( '*' . join(str(k) for k in L*3))
[A] TypeError
[B] 'None*None*None'
[C] None*None*None
[D] None*None*None*
Q.24 Given the following code, what will be the output shown?
def FN(x):
x=x-4
return x
print(sqrt(x))
FN(40)
[A] 36
[B] 6.0
36
[C] no output
Q.25 A student register is maintained using a dictionary having the roll numbers as the key
and value being students First_name ,Last_name stored as a list, a sample of which is shown
below:
The first_name and Last_name should be uniformly changed to have their first letter
capitalized, so that the Stud_List now contains:
Given the following code to do the above, which option(s) can fill in the blank appropriately, to
get the desired result.
for k in Stud_List:
Stus_List [k]= _______________
Q.26 A text file “Content.txt” exists with the content: Python Coding is Interesting
Given:
F = open(“Content.txt”, “a+”)
F.seek(6)
F.write(“Easy”)
F.close()
[C] Easy
F = open(“Story.txt”)
for k in F : print(k) - will display the file contents one line at a time
: Page 8 :
Reason (R) : When we iterate through the file handler used to open a file in read mode, the
loop variable moves through the file line by line
[B] Both A and R are true and R is not the correct explanation of A
F = open(“Story.txt”, “w”)
The above code creates a file Story.txt with 3 lines of text written in separate lines.
Reason (R) : The write() does not add any extra character like ‘\n’
[B] Both A and R are true and R is not the correct explanation of A
F = open(“Story.txt”, “a”)
print(F.tell())
Reason (R) : When the file is opened in ‘a’ mode, the file pointer is automatically
positioned at the end.
[B] Both A and R are true and R is not the correct explanation of A
Q.30 Reshma tried the following code to store details of 3 students in the form of a CSV file:
import csv
F =open(“Student.csv”, “w”)
W= csv.writer(F)
W.writerows([1, “AAA”], [2, “BBB”], [3,”CCC”])
F.close()
: Page9 :
But when she retrieved the records and displayed, an empty record was displayed between
records.
Statement1: A CSV file can only be created with empty records between records
Statement2: Omitting the newline argument in the open() function causes EOL translation to
take place.
A student register having details of Roll number, name, age and marks are maintained in an
existing “Student.csv” file. The marks of one student has to be changed given the roll
number of the student. A code has been created with certain portions left blank. Fill in the
blanks appropriately using the specifications and the options given:
R_Obj= csv.reader(F)
_________ #statement 1
if _________________ : #statement 4
rec[3] = NewMark
W_Obj.writerow(rec)
__________ #statement 5
Q. 31 Choose the option for statement 1 to store the contents of the csv file into a list
[C] F = list(Lst)
Q.32 Choose the option for statement 2 to open the file to rewrite the modified contents:
[A] csv.writer(FileObj)
[B] csv.writer(F)
[C] csv.Writer(FileObj)
Q. 34 Choose the option for statement 4 to check if the roll number of each record matches
with the parameter passed:
[C] int(rec[0]) == R
[D] rec[0] = R
Q.35 Choose the option for statement 5 to invoke the function to change the marks of student
with roll number 12501 to 93:
[C] Modify_Student(“student.csv”)
---------------------------------------------------