Professional Documents
Culture Documents
A. function name
B. parameter list
C. return value
D. Both A and B
Q.5-What is called when a function is defined inside a class? [1]
A. class
B. function
C. method
D. module
Q.6-What is a recursive function? [1]
A. def fun(a = 2, b = 3, c)
B. def fun(a = 2, b, c = 3)
C. def fun(a, b = 2, c = 3)
D. def fun(a, b, c = 3, d)
Q.9-How many objects and reference variables are there for the given Python code? [1]
class A:
print("Inside class")
A()
A()
obj=A()
A. 2 and 1
B. 3 and 3
C. 3 and 1
D. 3 and 2
Q.10- CSV File
1, AKSHAY, XII, A
2,ABHISHEK, XII, A
3,ARVIND, XII, A
4,RAVI, XII, A
5,ASHISH, XII ,A
Incomplete Code
import_____ #Statement-1
fh = open(_____, _____, newline='') #Statement-2
stuwriter = csv._____ #Statement-3
data = []
header = ['ROLL_NO', 'NAME', 'CLASS', 'SECTION']
data.append(header)
for i in range(5):
roll_no = int(input("Enter Roll Number : "))
name = input("Enter Name : ")
Class = input("Enter Class : ")
section = input("Enter Section : ")
rec = [_____] #Statement-4
data.append(rec)
stuwriter. _____ (data) #Statement-5
fh.close()
i. Identify the suitable code for blank space in line marked as Statement-1. [1]
a) csv file
b) CSV
c) csv
d) Csv
ii. Identify the missing code for blank space in line marked as Statement-2? [1]
a) "School.csv","w"
b) "Student.csv","w"
c) "Student.csv","r"
d) "School.csv","r"
iii. Choose the function name (with argument) that should be used in the blank [1]
space of line marked as Statement-3
a) reader(fh)
b) reader(MyFile)
c) writer(fh)
d) writer(MyFile)
iv. Identify the suitable code for blank space in line marked as Statement-4. [1]
a) 'ROLL_NO', 'NAME', 'CLASS', 'SECTION'
b) ROLL_NO, NAME, CLASS, SECTION
c) 'roll_no','name','Class','section'
d) roll_no,name,Class,sectionc) co.connect()
v. Choose the function name that should be used in the blank space of line marked as Statement-
5 to create the desired CSV File? [1]
a) dump()
b) load()
c) writerows()
d) writerow()
Q.11- Which of the following commands is used to open the file
“STUDENT.DAT” for writing only in binary format? (marked as #1 in the
Python code)
a. F= open("STUDENT.DAT",'wb')
b. F= open("STUDENT.DAT",'w')
c. F= open("STUDENT.DAT",'wb+')
d. F= open("STUDENT.DAT",'w+')
c. indicates that the next read or write occurs from that position in a file.
def test(i,j):
if(i==0):
return j
else:
return test(i-1,i+j)
print(test(4,7))
a) 13
b) 7
c) Infinite loop
d) 17
def a(n):
if n == 0:
return 0
else:
return n*a(n - 1)
def b(n, tot):
if n == 0:
return tot
else:
return b(n-2, tot-2)
a) Both a() and b() aren’t tail recursive
b) Both a() and b() are tail recursive
c) b() is tail recursive but a() isn’t
d) a() is tail recursive but b() isn’t
Q.15-