KVS Chandigarh Region Paper
KVS Chandigarh Region Paper
KVS Chandigarh Region Paper
Q. Section - A
No
This section consists of 25 Questions (1 to 25). Attempt any 20 questions from this section. Choose the best
possible option.
Data=F.read(10).
Which of the following statement is True regarding variable Data
a) Data contains list of 10 lines
b) Data contain list of 10 characters
c) Data contains string of 10 characters
d) Data contains integer value 10
16 Assume that the position of the file pointer is at the beginning of 3rd line in a text file. Which of the
following options can be used to read all the remaining lines?
a) myfile.read(n-3) b). myfile.read(n)
c) myfile.readline() d) myfile.readlines()
17 Which of the following statements is not correct?
a) If we try to read a text file that does not exist, an error occurs.
b) If we try to read a text file that does not exist, the file gets created.
c) If we try to write on a text file that does not exist, no error occurs.
d) If we try to write on a text file that does not exist, the file gets created.
18 To read data from binary file _____ function is used ?
a) pickles.load(file_object) b) file_object.load(object)
c) object=load(file_object) d) object=pickle.load(file_object)
19 file.seek(56,0), What relative stream position 0 represent in given seek function?
a) Relative to beginning of file b) Relative to end of file
c) Relative to current position of file d) None of the above
20 The process of converting the structure to a byte stream before writing to the file is known as _____
Pickling b) Unpickling c) Dump d) Load
21 The ________ paths are from the topmost level of the directory structure.
a) Direct b) Relative c) Absolute d) Parent
22 Name the error which raised by pickle.load( ) function when it reaches end of file while reading
binary file?
a) fileError b) ErrorEndofFile c) EOFError d) FileEndError
Page 2 of 9
23 Name the function to read from CSV file.
a) read() b) csv.reader() c)csv_read() d) read_csv()
24 Write full form of CSV
a) Comma separated values b) Comma settled values
c) Common separated values d) None of the above
25 -
a) new data will be added at the end of file
b) new data will be added at the beginning of file
c) Old data will be lost and new data will be stored.
d) An Error will occur.
Section B
This section consists of 24 Questions (26 to 49). Attempt any 20 questions from this section. Choose the
best possible option.
26 What will be the output of following Python Code:
if 5>2 or 8<5 and 0 :
else:
a) 50 # 51 # 52 # 53 # 54 # 55 # b) 54 # 53 # 54 # 55#
c) 53 # 54 # 55 # 56 # d) 51 # 52 # 53 # 54 # 55
Page 3 of 9
31 What will be the output of following Python Code:
data=[10,"ram",20,"sham",30,"anil"]
data.append("Sunil")
data[2]="Raj"
data.pop()
del data[1]
data[-1]="Magic"
print(data)
a) [10, 'Ram', 'sham', 30, 'Sunil'] b) [10, 'Raj', 'sham', 30, 'Magic']
c) [10, 'Magic', 'sham', 30, 'Sunil'] d) [10, 'Ram', 'sham', 30, 'Magic']
32 What will be the output of following Python Code:
def evenodd(num):
for i in range(len(num)):
if num[i]%2==0:
num[i]/=2
else:
num[i]*=2
return num
#main-coding
numbers=[10,15,20,25]
print(evenodd(numbers)) #function call
a) [5, 30, 10, 25] b) [5.0, 30, 10.0, 50]
c) [20.0, 7.5, 40.0, 12.5] d) [20, 15, 40, 12.5]
33 What will be the output of following Python Code:
def convert(name):
N=' '
for k in name:
if k.isupper():
N=N+k.lower()
elif k.islower():
N=N+k.upper()
else:
N=N+k
print(N)
#main-coding
convert('Term-1#EXAM')
a) tERM-1#exam b) Term-1#EXAM
c) exam-1# tERM d) #EXAM Term-1
34 What will be the output of following Python Code:
G=10
def fun1():
global G
G=20
print(G, end="*")
G=G+10
fun1( ) #call to fun1
print(G)
a) 10*20 b) 20*30 c) 20*20 d) 10*10
Page 4 of 9
35 Suppose the content of "Myfile.txt" is :-
a) 4 b) 5 c) 6 d) 3
36 -
Always Think Positive,
Never THINK Negative
What will be the output of the following Python code?
file1=open("story.txt","r")
data=file1.read( )
word=1
k=data.split()
for i in k:
if i.upper()=="THINK":
word=word+1
print(word)
file1.close()
a) 0 b) 1 c) 2 d) 3
37 -
Twinkle twinkle little star
How I wonder what you are
Up above the world so high
Like a diamond in the sky
Twinkle twinkle little star
Page 5 of 9
38 What will be the output of following Python Code:
A,B=20,10
if A<B:
break
else:
File1.close()
File2.close()
a) God One GOD God b) God One God you
c) God One GOD God you d) God GOD God
40 Raj has written following program to copy story.txt file data into file kahani.txt. Help Raj to
complete the program by choosing correct option to fill in blank.
# Program to copy Story.txt file into new file Kahni.txt
file1=open("story.txt","r")
file2=open("kahani.txt","w")
data=file1.read()
__________________ # to write data in kahani.txt
file1.close()
file2.close()
print("File copied")
a) file1.writedata() b) file2.writedata( ) c) file1.write(data) d) file2.write(data)
41 Syntax of seek function in Python is myfile.seek(offset, reference_point) where myfile is the file
object. What is the default value of reference_point?
a) 0 b)1 c) 2 d) 3
42 The content of text file INSTITUTE.TXT is :
KVS is a great organization
What will be the content of INSTITUTE.TXT after execution of following Python code:
file1=open("INSTITUTE.TXT","w")
file1.close()
a) KVS is a great organization of India b)KVS is a great organization of World
c) KVS is a great organization d)of India
Page 6 of 9
43 Raj is trying to write an object obj1 = (1,2,3,4,5) on a binary file "test.dat". Consider the following
code written by him.
import pickle
obj1 = (1,2,3,4,5)
myfile = open("test.dat",'wb')
pickle._______ #Statement 1
myfile.close( )
Identify the missing code in Statement 1.
a) dump(myfile,obj1) b) dump(obj1, myfile)
c) write(obj1,myfile) d) load(myfile,obj1)
44 The content of binary file STUDENT.DAT is :
Page 7 of 9
46 -
Always Think Positive
#main-coding
data=[10,20,30,40,50,60]
change(data)
print(data)
a) [10, 20, 30, 40, 50, 60] b) [60, 50, 40, 30, 20, 10]
c) [20, 10, 40, 30, 60, 50] d) [40, 50, 60, 10, 20, 30]
49 Consider following Python Code and tell which line(s) have error(s):-
Page 8 of 9
Section - C
This section consists of 6 Questions (50 to 55) on case study base. Attempt any 5 questions from
this section. Choose the best possible option.
contain employee-code, employee-name and Salary for some entries. She has written the following
code. As a programmer, help her to successfully execute the given tas k
import _____________ #line-1
#Function to add / write single Employee records
def addemployee(record):
csvobj=csv.__________(file1) #line-2
csvobj._____________(record) #line-3
file1.close()
#Function to read employee records
def reademployee():
) #line-4
csvobj=csv._______(file1) #line-5
for rec in csvobj:
if int(rec[2])>15000:
print(rec)
file1.close()
#main-coding
rec1=[101,'ram',10000]
rec2=[102,'sham',20000]
rec3=[103,'sita',15000]
addemployee(rec1)
addemployee(rec2)
addemployee(rec3)
reademployee() #line-6
52 Fill in the blank in Line 3 to write record / data of one student in CSV file.
a) writer b) writerow c) writerows d) writeline
53 Fill in the blank in Line 4 with file open mode for reading data from CSV file
Page 9 of 9