Professional Documents
Culture Documents
Chennai Set2
Chennai Set2
Chennai Set2
General Instructions:
The question paper is divided into 3 Sections - A, B and C.
Section A, consist of 25 Questions (1-25). Attempt any 20 questions.
Section B, consist of 24 Questions (26-49). Attempt any 20 questions.
Section C, consist of 6 case study based Questions (50-55). Attempt any 5 questions.
All questions carry equal marks.
Q.N. Section - A
This section consists of 25 questions (1 to 25). Attempt any 20 questions from this
section. Choose the best possible option.
1. Find the invalid identifier from the following:
(a) Twelfth_C (b) _12C
(c) 12th_C (d) For
2. Consider a declaration t = [12101, 'Ashok', 17].
Which of the following represents the data type of t?
(a) list (b) tuple
(c) dictionary (d) string
3. Consider the following code and find the correct output from the given options:
t1=(12,30,44,52,36)
print(t1.index(3))
(a) 44 (b) 52 (c) 36 (d)12
4. Which option correctly explains tell () method?
(a) tells the current position within the file.
(b) tells the name of file.
(c) moves the current file position to a different location.
(d) it changes the file position only if allowed to do so else returns an error.
5. Which of the following command is used to open a file “d:\emp.txt” in read-mode only?
(a) f1 = open(“d:\emp.txt”, “r”)
(b) f1 = open(“d:\\emp.txt”, “r”)
(c) f1 = open(file = “d:\emp.txt”, “r+”)
(d) f1 = open(file = “d:\\emp.txt”, “r+”)
6. Which of the following commands can be used to read 12 characters from a file using the
file object <f1>?
(a) f1.read(12) (b) f1.read()
(c) f1.readline(12) (d) f1.readlines()
7. Which of the following statement is incorrect about the opening modes of a file?
(a) When you open a file for reading, if the file does not exist, an error occurs.
(b) When you open a file for reading, if the file does not exist, the program will
open an empty file.
(c) When you open a file for writing, if the file does not exist, a new file is
created.
(d) When you open a file for writing, if the file exists, the existing file is
overwritten with the new file.
8. Which operator is used for replication?
(a) + (b) % (c) * (d) //
9. Consider the tuple in python named sub=( “cs”, “phy”, “mat”).
Identify the invalid statement(s) from the given below statements:
(a) s=sub[1]
(b) print(sub[2])
(c) sub[0]= “ip”
(d) list=list(sub)
10. Find the output of the following:
>>> test="Comp Sc Periodic Test"
>>> print(test[:3:-1])
(a) seT cidoireP cS
(b) tseT cidoireP
(c) tseT cidoireP cS
(d) tseT cidoireP cs
11. Which of the following function is used to write data in binary mode?
(a)write (b)output
(c)dump (d)send
24. Which of the following function is used to read data from a binary file?
(a) write
(b) load
(c) dump
(d) scan
25. An absolute path name begins with:
(a) Leaf
(b) Stem
(c) current directory
(d) root
Section – B
This section consists of 24 Questions (26 to 49). Attempt any 20 questions.
26. Predict the output of the following code:
sub=["CS", "PHY", "CHEM", "MATHS", "ENG"]
del sub[2]
sub.remove("ENG")
sub.pop(1)
print(sub)
(a) ['CS', 'MATHS']
(b) ['CS', ‘ENG’]
(c) [‘CS’,’CHEM’]
(d) [‘PHY’,’CHEM’]
27. Suppose content of 'lang.txt' is:
It is interpreted.
It is highlevel.
Indentation is important.
What will be the output of the following code?
f1 = open("lang.txt")
res = f1.readline()
print(len(res))
f1.close()
(a) 18
(b) 19
(c) 16
(d) 17
28. Identify the output of the following Python statements.
d={2:{1:'one',2:'two'},3:{1:'one',2:'two',3:'three'},4:{1:'one',2:'two',3:'three',4:'four'}}
print(d[4][3])
(a) one (b) two (c) three (d) four
29. Identify the output of the following Python statements.
l=[10,'to']
for i in range(len(l)):
print(l[i]*2)
(a) 10 (c) 100
to toto
(b) 100 (d) 20
to*to toto
s=1
for i in range(1,10):
if i%2!=0 and i<7:
print(i)
_______________ # Statement 1
Write appropriate jump statement from the following to obtain the above output.
(a) break (b) jump
(c) continue (d) return
res = div(20,3)
print(res)
(a) (6, 2) (b) [6,2] (c) 6.66 (d) 6
35. Evaluate the following expression and identify the correct answer.
51 + 13 / 2 – 4 + 3 ** 2 - 5
(a) -28 (b) 57 (c) 39 (d) 32
36. What will be the output of the following code?
def calc(a,b=2,c=3):
a=a+5
c += a * b
return c
res1 = calc(5)
res2 = calc(6,1)
print(res1, res2)
(a) (23,14) (b) (23,25) (c) (25,14) (d) (14,25)
37. What will be the output of the following code?
a = 15
def update(x):
global a
a += 2
if x%2==0:
a *= x
else:
a //= x
a=a+5
print(a, end="$")
update(5)
print(a)
(a) 20$11 (b) 15$4 (c) 20$4 (d) 22$4
38. Choose the impossible output from the given options on successful execution of the
following code:
import random
sub=["CS","Maths","Phy","Chem","Eng"]
for i in range(5):
y = random.randint(1,4)
print(sub[y],end="@")
(a) Final\Infrastructure
(b) D:\Data\Final\Infrastructure
(c) ..\Final\Infrastructure
(d)..\Shapefiles\Final\Infrastructure
48. Assume the content of text file, 'legend.txt' is:
Diego Maradona.
Argentinian soccer legend.
celebrated Hand of God scorer.
dies at 60.
What will be the data type of res?
f1 = open("legend.txt")
res = f1.readline()
f1.close()
(a) tuple (b) string (c) list (d) dictionary
49. What will be the output of the following code?
msg2=""
msg1="All the very best"
msg2=msg1
msg2 +=" for the exam"
print(msg1)
(a) All the very best for the exam (b) for the exam
(c) All the very best (d) Error Message
Section - C
Case Study based Questions
This section consists of 6 Questions (50 - 55) Attempt any 5 questions.
Pinki of Class 12 is writing a program to add 10 more records to an existing CSV file
“payroll.csv” which will contain employee id, employee name, designation and salary
fields. She has written the following code. As a programmer, help her to successfully
execute the given task.
Incomplete Code
__________________ #Statement-1
f1 = open(_____, _____, newline='') #Statement-2
empw = csv._____ #Statement-3
details = [ ]
for i in range(10):
empid = int(input("Enter Employee Id : "))
empname = input("Enter Employee Name : ")
designation = input("Enter Designation : ")
salary = int(input("Enter Salary : ") )
record = [ _____ ] #Statement-4
details.___________ (record) #Statement-5
empw. dump ( ___________ ) #Statement-6
f1.close()
50. Identify the suitable code for blank space in the line marked as Statement-1.
(a) load CSV (b) read csv
(c) import csv (d) import CSV
51. Identify the missing code for blank space in line marked as Statement-2.
(a) "payroll.csv","wb"
(b) "payroll.csv","a"
(c) "payroll.csv","w"
(d) "payroll.cvs","a"
52. Choose the function name (with argument) that should be used in the blank space of line
marked as Statement-3.
(a) writer(f1) (b) reader(f1)
(c) read(f1) (d) write(f1)
53. Identify the suitable code for blank space in line marked as Statement-4.
(a) “empid”,”empname”,”designation”,”salary”
(b) empid,empname,designation,salary
(c) EMPID,NAME,DESIGNATION,SALARY
(d) empid,name,designation,salary
54. Identify the suitable code for blank space in the line marked as Statement-5.
(a) load (b) write
(c) append (d) dump
55. Choose the function name that should be used in the blank space of line marked as
Statement-6 to create the desired CSV File?
(a) record (b) details
(c) empw (d) csv