0% found this document useful (0 votes)
147 views10 pages

Computer Science Set-B BSSC Term I

1) In-built functions are functions that are already available in Python and do not need to be defined by the programmer. These functions include functions like print(), len(), sorted(), etc. 2) The call stack is the area of memory that stores the parameters and local variables of a function call. 3) CSV stands for comma separated values, where values in a file or table are separated by commas. This summarizes the key details about in-built functions, call stack, and CSV format provided in the first 3 questions of the document in 3 sentences.

Uploaded by

Kavin Satya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
147 views10 pages

Computer Science Set-B BSSC Term I

1) In-built functions are functions that are already available in Python and do not need to be defined by the programmer. These functions include functions like print(), len(), sorted(), etc. 2) The call stack is the area of memory that stores the parameters and local variables of a function call. 3) CSV stands for comma separated values, where values in a file or table are separated by commas. This summarizes the key details about in-built functions, call stack, and CSV format provided in the first 3 questions of the document in 3 sentences.

Uploaded by

Kavin Satya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

dADHIKA XFA

BANGALORE SAHODAYA SCHOOL COMPLEX


PREBOARD EXAMINATION TERM 1
Class: Xl B
Session: 2021-22
Maximum Marks: 35
Computer Science (Code 083)
General Instructions: Time Allowed: 90 Minutes
1. This
question
paper contains three parts A, B and C. Each
2. Section A has 25
- part is compulsory.
3. Section B has 24
questions [1-25], attempt any 20 questions.
4. Section C has 6 questions [26-49], attempt any 20 questions.
-

Case study based


5. All
programming questions are to bequestion [50-55]. Attempt any 5
answered in Python question
language only.
mmmmmm

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?

aHeap b)Queue c)Stack d)Array


3. CSV stands for

a)Column Separated Values b)Comma Separated Values


c)Comma Started Values d)Column Separated Values
4. What would be the minimum and maximum value of z (random module has already been

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

5. A void function also returns a, value to its caller.

a) int b) String )None d) Boolean


18. A python code
6. Sam wants to vote for the upcoming election because his age is below
is written to check his age identify it is correct orincorrect
SL. N
.

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

a) af1.read(12) bf1.read() cf1.readline() d)read(f1,12)


9. Consider a list num
(c) =
[5, 10, 15, 20], which of the following will result in an
error:
a)num[0]+=3 b) num += 3 c) num =3 d) num[1] = 45
10. Find the
operator which cannot be used with string in
a
Python from the following:
a) // b) c)+ d) in
3 11. Which of the
following is not a feature of Python function:-
a) Modularity
b) Simplicity
val c) Reusability
d) difficult to find error
12. Which is the
correct dictionary declaration?
a)d1={1:January',2='February',3:'March'} b)d2-(1:January',2:'February',3:'March'}
c)d3={1:January',2:'February',3:'March'} d)d4={1:January,2:February,3:March)
13. Consider a
tuple in python named Months ('Jul, 'Aug, =
'Sep'). Identify the invalid
statement(s) from the given below statements:-
a)S = Months[0]

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

19. Find out the type of error if any- be


if v <5:
print("Hello World")
else:
print("Good to see you!")
a) No Error b)Declaration of v
c): with else not required d) Indentation Error

20. Which of the following is valid variable name:-


a) Student name b) 3Number c)%name% d)Block_number
21. When you open a file for adding more data, if the file does not exist, an error occurs.
a) True b)False
22. Consider square numbers defined as follows:
compute(1) = 1

compute(N) = compute(N-1) + 2N-1

According to this definition, what is compute (3)?


a) compute(3) compute(2) +compute(1) bJcompute(3) compute(2)-2*3+1
=
=

b) compute(3) = compute(2) + 2*3-1 d)compute(3) = compute(3) +2*3-1


23. The value of the expressions 4/(3* (4-2)) and 4/3*(4-2) is the same. oqe ebepl
a) True b) False
24. What will the following code produce?
T=[kvs','rpr]
1=range(len(T)

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

b) Argument c)Parameter c) Keyword Argument


a) Argumentation
27. What is the output of the following program:
print(0.1+0.2 ==0.3)
a)True b)False c)Machine Dependent d)Error
28.
tie ="blue'
def dress(0:
shoe="brown'

In above code tie isa variable while shoe is a. variable.


a) Global, Local b) Global, Default c) Default, Local d)Dynamic, Local
29. Suppose content of "data.txt' is

CBSE XII Pre Board.


What will be the output of the following code?

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)

31. Which of these about a dictionary is false?


a) The values of a dictionary can be accessed using keys
b) Dictionaries aren't ordered
values
The keys of a dictionary can be accessed using
d) Dictionaries are mutable

32.Find and write the output of the following python code:

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)T=T+66 b)T =T+66 c)T= T+ (66,) d)T= T+(66)


35. Evaluate the expression.
a = [5,4,3,2,2,2,1]
a=a [a [a [a [0]+1]]]
print(a)
a)3 b)4 c)5 d)2
36. Which of the following is the use of id() function in Python?

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

38. What is the output of the following code snippet?

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="#")

a) 5#8#15#4# b) 5#8#5#4# c) 5#8#15#14# d) 5#18#15#4#


39. Evaluate the following expression and identify the correct answer.
18-(1+2) * 5+2**5 *4

a) 131 b) 146 C)181 d) 132

40. Suppose content of'India.txt is

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))

a)0:0 b)2:4 c)1:6 d)0:5


is:
text file, 'student.txt'
43. Assume the content of
Kaustubh
Pranav Kumar
Dilshad

Amrita

of filedata?
What will be the data type
fileread =open("student.txt")
filedata = fileread.readlines()
fileread.close()

b. list c. tuple d. dictionary


a. string

44. Consider the following directory structure.


Computer Science
Java soL
OPyhon
Topic2.bxt Topic3.txt
Topic.bxt Topic1.bxt
the same. What will be
and present working directory are
Suppose root directory (Computer Science)
the absolute path of the file Topic.txt?

b) Computer Science/Python/Topic.txt
a) Computer ScienceTopic.txt
c) Computer Science/Python/../Topic.txt
d) Computer Science/C++/Topic.txt

45. Suppose content of 'quote.txt'is


Don't stop until you are Proud.|
What will be the output of the following code?
myfile = open("quote.txt")
record = myfile.read().split()

print{len(record))
myfile.close()
c) 6 d) 7
a) 4 b) 5

46. Suppose content of 'Myfile.txt' is

Twinkle Twinkle little star


are
|How Iwonder what you
Up above the world so high
Like a diamond in the sky
Twinkle Twinklelittle star
What will be the output of the following code?
myfile = open("Myfile.txt")
line_count = 0
data = myfile.readlines()
for line in data:
if line[0] == 'T':
line_count+= 1
print(line_count)
myfile.close()

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?

(a) 2 34 b) 9 16 16 (c) 164 16 (d) 2 49


49. Priya is trying to write a tuple num = (11,12,13,14,15) on a binary file number.bin.
Consider the following code written by him.
Class
Da
import pickle
num = (11,12,13,14,15)

fileread= open("number.bin", wb')


pickle #Statement 1
fileread.close()
Identify the missing code in Statement 1.
a) dump(fileread, num) b) dump(num, fileread)
c) write(num,fileread) d) load(fileread, num)

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

programmer, help him to successfully execute the given task.

import # Line 1
def add(Name,Phno):
f=open('studentdata.csv' ) #Line 2
newFileWriter = csv.writer(f)

newFileWriter. ([Name,Phno]) # Line 3


f.close()
def readFile():
newFile = open(' studentdata.csv,r)

newFileReader = csv. (newFile) # Line 4


for row in newFileReader:
print (row[0], "->", row[1])
newFile # Line 5
add("Pranav", "9839988295")
add("Sunaina", "7760412064")
add("Manish", "9739556636")
readFile() #Line 6

50. Name the module he should import in Line 1.

(a) pickle (b) csv (c) file (d) random

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.

(a) load() (b) read() c) reader() (d) readlinel)


54. Fill in the blank in Line 5 to close the file..

(a) close() (b) Close() (c) CLOSE() (d) end()


55. Write the output he will obtain while
executing Line 6.
(a) Pranav 9839988295 (c) Pranav-> 9839988295
Sunaina 7760412064 Sunaina-> 7760412064
Manish 973955663 6 Manish -> 9739556636
(b) "Pranav" "9839988295" (d) "Pranav" -> "9839988295"
"Sunaina" "7760412064" "Sunaina" -> "7760412064"
"Manish" "9739556636" en e
"Manish"->"9739556636"

*****************

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy