Computer Science Set-B BSSC Term I
Computer Science Set-B BSSC Term I
Section- AA
This section consists of 25
Questions (1 to 25). Attempt any 20 questions from this
section. Choose the best possible
option.
1. A Programmer is working in Python program which is function oriented.
He/She is using
the functions already available in
python. These functions are called:
a) User Defined Function b) Modular Function
c) In-built Function d) Reusable Function
2. What is the area of memory called, which stores the parameters and local variables of a
function call?
imported) ?
X=random(2,6)
Y= random(1,2)
Z=X+Y
print(Z)
a)min:1 max:2 b)min:2 max:6 c)min:3 max:8 d)min:1 max:8
Age=input("enter
if Agec=18:
age:")oo rooisaeAMoe
print("you are not eligible to Vote)
a) Correct b)Incorrect
2.
7. What is the default mode of opening a file in python?
a)read b)write clappend d)read and write
Th 8. To read twelve characters from a file
object f1, we use
c) Months[1] = "Oct'
b)print(Months[2]) dbeneammote
d)LIST1 =list(Months) ar
14. Which of the following
expressions is an example of type casting?
a)4.0+float (6) b)5.3+6.3 c)5.0+3 d)None of these
15. What will be the output after the following statements?
a = [0, 1, 2, 3]
del a[:]
print(a)
a)None b) cHO, 1, 2, 3] d)NameError
16. What will be the output after the following statements?
X = 27
y= 19
whilex < 30 and y > 15:
X=x+1
Y=y-1
print(x,y)
a) 26 11 b) 25 11 c) 30 16 d) 26 10
17. In which of the
following file modes, the existing data of file will be lost?
ala bJab c)rb dw
18. Which is NOT the possible output of following program from given options:
import random
periph= ['Mouse', 'Keyboard', 'Printer, 'Monitor]
for i in range (random.randint(0,2)) :
print(periph[i],*",end=" ")
(A) Mouse *Keyboard* (B) Mouse *Keyboard* Printer*
(C) Mouse* (D) No output
for i in T1:
T[il=T[i].upper()
print(T)
b)['kvs', rpr]
a)['KVS','rpr]
[KVS', RPR]
[KVS','RPR]
d)Error
c)IKvs',Rpr]
['KVS', 'RPR']
the directory.
25. The relative path for a file never changes after changing
b) False
a) True
Section B
20 questions.
This section consists of 24 Questions (26 to 49). Attempt any
function call?
26. What is the value called that is passed during the
fileread open("data.txt")
X = fileread.read()
print len(x))
fileread.close()
a)5 b)19 c) 26 d)20
30. What will be the output of the following code? e b o h e sdfde-
tup1 = (1,2,[1,2],3)
tup1[2][1]-3.14
print(tup1)
d. Error Message
a. (1,2,[3.14,2],3) b. (1,2,[1,3.14],3) c. (1,2,[1,2],3.14)
a=10
def call():
global a
a=15
b-20
print(a)
call)
a)25 b)15 c)35 d)10
result in error?
33.Which of the following Python codes will an
obj= 'a'
a)pickle.dumps(obj) b)pickle.dumps(obj,3)
cpickle.dumps (obj, 3, True) d)pickle.dumps('a',2)
34. Identify the correct option to add new value 50 to existing tuple T
T= (11,22,33,44,55)
a) ld returns the identity of the object b) Every object doesn't have a unique ID
c) All of the mentioned d) None of the mentioned
statements?
after the following
37. What will be the output
x=4
y= 8
while x + y< 20:
print(x, end="")
X+= 2
c)0 2 46 d)0 2 4 8
a)0 2 4 6 b)4 6 8 10
def ChangeVal(M,N):
for i in range(N):
ifM[i]%5 ==0:
M[l//=5
ifM[j9%3 ==0:
M[il//=3
L= [25,8,75,12]
ChangeVal(L,4)
for i in L:
printi,end="#")
secular
India is a country
What will be the output of the following code?
fileread =
open("India.txt")
volist = list("aeiouAEIOU")
Vc-0
x =fileread.read()
for y in x:
if y in volist:
VC+=1
print/vc)
fileread.close()
a) 10 b) 7 c) 8 d) 9
41.ldentify the output of
the following Python statements.
x= [[10, 11, 12],[13, 14, 15]]
y= x[O][1]
print(y)
b. 13 C. 14 d. 15
a. 11
42. What is the output of
the program given below:
import random
x= random.random()
y random.randint(0,4)
print(int{x),"", y+int{x))
Amrita
of filedata?
What will be the data type
fileread =open("student.txt")
filedata = fileread.readlines()
fileread.close()
b) Computer Science/Python/Topic.txt
a) Computer ScienceTopic.txt
c) Computer Science/Python/../Topic.txt
d) Computer Science/C++/Topic.txt
print{len(record))
myfile.close()
c) 6 d) 7
a) 4 b) 5
a)2 b) 3 c) 4
d5
47.
Assertion (A): Parameters with default arguments can be followed by parameters with no
default argument.
Reason (R): Syntactically, it would be impossible for the interpreter to decide which values
match which arguments if mixed modes were allowed while providing default arguments.
(a) A is true but R is false.
(bYA is false but R is true.
(c) Both A and R are false.
(d) Both Aand Rare true but Ris not the correct explanation of A. e
(e) Both A and R are true and R is the correct explanation of A.
48. Consider the following code:
import math, random
print(str(int(math.pow(random.randint(2,4),2) end=')
print(str(int(math.pow(random.randint{3,A),2)end= ")
print(str(int(math.pow(random.randint(4,4),2)
What could be the possible outputs out of the given four choices?
Section-C
(This section consists of 6 Questions (50-55) Attempt any 5 questions.)
Ayush of class 12 is writing a program to create a CsV file "studentdata.csv which will
contain Name and Phone no as entries. He has written the following code. As a
import # Line 1
def add(Name,Phno):
f=open('studentdata.csv' ) #Line 2
newFileWriter = csv.writer(f)
51. In which mode, Shubham should open the file to add data into the frile.(Line 2)
(a) w+ (b)r (c) r+ (d) a
52. Fill in the blanks for Line 3 write the data to CSV file.
(a) writerow() (b) writerows() (c) Writerows() (d) writerRow()
53. Fill in the blank in Line 4 to read the data from a csv file.
*****************