0% found this document useful (0 votes)
41 views11 pages

Virendra Public School12 Term1 Comp

Uploaded by

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

Virendra Public School12 Term1 Comp

Uploaded by

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

VIRENDRA PUBLIC SCHOOL

CLASS XII
COMPUTER SCIENCE (083)(science)
TERM I(PREBOARD 1)-2021-22

Maximum Marks: 35 Time Allowed: 90 Minutes

General Instructions:
1. The question paper is divided into 3 Sections – A, B and C.
2. Section A consists of 25 Questions (1-25). Attempt any 20 questions.
3. Section B consists of 24 Questions (26-49). Attempt any 20 questions.
4. Section C consists of 6 case study based questions (50-55). Attempt any
5 questions.
5. All questions carry equal marks.

Section A
This section consists of 25 Questions (1 to 25). Attempt any 20 questions
from this section. Choose the best
possible option.
1. In Python, the terms ‘global’, ‘else’ and ‘pass’ are used to refer to:
(i) Literals (ii) Keywords
(iii) Variables (iv) Punctuators
2. Take these numbers into consideration: 2,5,6,3,5,2,1,7. Write a command
that declares a tuple named A
with these integers as elements.
(i) A = (2,5,6,3,5,2,1,7) (ii) A = 2,5,6,3,5,2,1,7
(iii) A = {2,5,6,3,5,2,1,7} (iv) A = [2,5,6,3,5,2,1,7]

3. Given a tuple Tup1=(25,35,43,22,13,56,45,78,90)


Identify the statement from the list below that will produce the result as
(25,43,13,45,90)
(i) print(Tup1[::]) (ii) print(Tup1[0:9:1])
(iii) print(Tup1[::2]) (iv) print(Tup1[2:0:9])
4. Which of the following statements is correct regarding file access
modes?
(i) In ‘r’ mode, we can read and write data from/in the file.
(ii) In ‘a’ mode, the existing data will be over-written if the file
exists.
(iii) In ‘w’ mode, the data in the file is retained and new data will be
appended to the end.
(iv) In ‘a+’ mode, both reading and writing operations can take place and
new data is appended to the end
of the existing file.
5. Which of the following options can be used to read the first five
characters of a text file ‘Poem.txt’ from
the file object File1?
(i) File1.read(4) (ii) File1.readlines(5)
(iii) File1.read(5) (iv) File1.read(6)

6. Consider a statement
fileobj = open(“myblog.txt”, ‘r’)
Which of the following options can be used to print the last line of a text
file ‘myblog.txt’?
(i) print(fileobj.readlines() -1)
(ii) disp = fileobj.readlines()
print(disp[-1])
(iii) print(fileobj.readlines(-1))
(iv) print(fileobj.read(-1))
7. Which of the following statements is used to open a text file to add new
contents at the end of the
already existing text file named ‘mydiary.txt’?
(i) with open(“’mydiary.txt”, ‘w’) as fileobj:
(ii) fileobj = open(“mydiary.txt”, ‘a’)
(iii) with open(“mydiary.txt”,’a’) as fileobj:
(iv) with open(“mydiary”, ‘r+’) as fileobj:
(a) Only (i)
(b) Only (ii)
(c) Both (ii) and (iii)
(d) Both (i) and (iv)
8. Write the output of the following code snippet.
x = ‘Rain’
z = 3
print(len(x) * z)
(i) 10 (ii) RainRainRain
(iii) 12 (iv) 3 3 3

9. Fill in the blanks with the appropriate operator to obtain the output.
31 ……… 3 = 10
(i) / (ii) %
(iii) // (iv) ^
10. Consider a tuple T1=(2,3,{1:‘One’,2:‘Two’,3:‘Three’}). Identify the
statement that will result
in an error.
(i) print(T1[3]) (ii) print(T1[0])
(iii) print(2 in T1) (iv) print(len(T1))

11. “The information is stored in machine-readable format and pickle module


is used for reading and writing
data from/in the file.”
Identify the type of file discussed in the above lines?
(i) Text files (ii) CSV files
(iii) Binary file (iv) All of the above

12. Assume that you are writing in a text file; now you want to identify
where the cursor is currently at in the
file. Which function will you use for the same?
(i) seek() (ii) hide()
(iii) tell() (iv) type()
13. Identify which function is used to write data in the binary file?
(i) seek() (ii) load()
(iii) dump() (iv) write()
14. Consider the statements given below:
Fileobj = open(“Report.txt”, ‘r’)
Fileobj.seek(25,0)
Choose the statement that best explains the second statement.

(i) It will place the pointer at 25 bytes ahead of the current file pointer
position.

(ii) It will place the pointer at 25 bytes behind from the end-of file.
(iii) It will place the pointer at 25 bytes from the beginning of the file.
(iv) It returns 25 characters from the 0 index.
th

15. Identify the incorrect statement regarding passing parameters to


functions.

(i) You can pass keyword arguments in any order.


(ii) You can pass positional argument in any order.
(iii) You can pass both positional and keyword arguments together.

(iv) An argument list must have any positional arguments followed by any
keyword arguments.
16. Identify the incorrect statement regarding declaration of default
parameters in function header.
(i) def Total_Amt(cost = 200, qty,disc= 0.2):
(ii) def Total_Amt(cost= 200, qty=20, disc):
(iii) def Total_Amt(cost, qty=20,disc=0.2):
(iv) def Total_Amt(cost, qty=20, disc):
(a) Only (ii)
(b) Both (ii) and (iii)
(c) Both (i) and (iii)
(d) Both (ii) and (iv)

17. Consider a function


def Cal_cube(n):
Which of the following function call can be used to invoke the given
function definition?
(i) Calc_cube(5): (ii) Calc_cube()
(iii) Calc_cube(5) (iv) Calc_cube(5,5,5)
18. Which of the following functions forces the writing of data on disc
which is still pending in the output
buffer?
(i) read() (ii) save()
(iii) flush() (iv) load()
19. Which of the following statements is correct regarding csv.writer()
object for storing data in the
csv file?
(i) Removes the delimiter characters from the data before storing it.
(ii) Returns a writer object which writes data into CSV file.
(iii) Creates rows
(iv) Creates columns
20. Which of the following is the default delimiter character in CSV file?
(i) / (ii) ,
(iii) : (iv) %
21. Which of the following groups of functions belongs to CSV module?
(i) reader(), writer() (ii) readlines(), writelines()
(iii) writerow(), read() (iv) writer(), readline()
22. In which mode are Python instructions stored in a file with .py
extension?
(i) Script mode
(ii) Run mode
(iii) Interactive mode
(iv) All of these

23. Which of the following statements is considered as multiline comment?


(i) /* Program to calculate Simple Interest. */
(ii) #Program to calculate
Simple Interest
(iii) ’’’Program to calculate

Simple Interest ’’’


(iv) // Program to calculate
Simple Interest //
24. Consider the statements given below:
import pickle Sample Question Paper 1
colors=[‘Red’,‘Green’,‘Orange’,‘Yellow’,‘Blue’]
with open(‘Mycolors.dat’,‘wb’) as mybinfile:
--------------------- #Statement1
Identify the missing code in Statement 1 that will write data from a list
on the binary file.
(i) pickle.load(mybinfile, colors)
(ii) pickle.dump(mybinfile, colors)
(iii) pickle.dump(colors, mybinfile)
(iv) pickle.load(colors, mybinfile)

25. Identify the statement that results in an error.


(i) Dict1 = {‘Cost’:120, ‘Qty’:10, ‘Amount’: 120}
(ii) Dict1 = {‘RollNo’ : 1, ‘Name’: ‘Shilpa’, ‘Marks’ : 90}
(iii) Dict1= (‘Marks1’: 80, ‘Marks2’: 90, ‘Marks3’: 96)
(iv) Dict1= { }

Section B
This section consists of 24 Questions (26 to 49). Attempt any 20 questions.

26. What is the correct declaration of a tuple P to obtain the following


output?
p = …………………
print(p*2)
Output: (240, 240)
(i) (240) (ii) “240”
(iii) (240,) (iv) (120)

27. Consider a file “myrhymes.txt”


If you’re happy and you know it, clap your hands (clap clap)
If you’re happy and you know it, clap your hands (clap clap)
If you’re happy and you know it, and you really want to show it.
If you’re happy and you know it, clap your hands (clap clap)

What will be the output of the following code?


fileobj=open('myrhymes.txt','r')
count = 0
l=fileobj.read()
word= l.split()
for i in word:
if(i=='clap'):
count=count+1
print(count)
fileobj.close()
(i) 9 (ii) 6
(iii) 3 (iv) 4

28. Identify the output of the following Python statements.


L1= [[‘Red’,’Green’],[‘Blue’,‘Yellow’,‘Orange’],
(
[‘Black’,‘White’]]

print(L1[2][0][3])
(i) ‘c’
(ii) ‘a’
iii) Black z=x//2
(iv) White

29. Identify the output of the following Python statements.


a=10
def call( ):
global a
a=15
b=20
print(a)
call( )
i) 15
ii) 20
iii) None
iv) can’t say
30. Identify the output of the following Python statements.
for i in range(10):
if i==5:
continue
print(i,end=’’)
(i) 0123456789
(ii) 012346789
(iii) 123456789
(iv) 12346789

31. Write the output of the following Python statements:


L1 = [1,2,3,4,5]
L2=[4,5,6]
L1.extend(L2)
L1.insert(4,9)
L1[-5:-2]
(i) [1, 2, 3] (ii) [4, 5, 6, 9]
(iii) [9, 5, 4, 5] (iv) [9, 5, 4]

32. What will be the output of the following code?


import pickle
list1 = ['Red','Green','Orange','Yellow','Brown']
fobj = open("file.dat",'wb')
l=pickle.dump(list1,fobj)
fobj.close()

fobj = open("file.dat",'rb')
l=pickle.load(fobj)
for i in range(len(l)-1,0,-1):
print(l[i])
fobj.close()
(i) Red (ii) Brown (iii) Yellow (iv) Brown
Green Yellow Orange Yellow
Orange Orange Green Orange
Yellow Green Red Green
Brown Red
33. Suppose the content of ‘Student.dat’ file is:

RollNo Name Amount Pending_Amt


1 Piyush 1000 0
2 Pragya 900 100
3 Shruti 600 400
4 Aryan 700 300
5 Payal 1000 0

What will be the output of the given code?

def Total_Amount():
f= open('Student.dat','rb')
total=0
pending=0
try:
while True:
R=pickle.load(f)
if R[2]==1000:
……………
total=total+R[2]
if R[3]>0:
pending=pending+R[3]
except:
f.close()
print("Total Amount due is ",total-pending)
Total_Amount()
When the Total_Marks() function is invoked, the output displayed is

Total Amount due is 200


Identify the appropriate jump statement from the following to obtain the
above output.
(i) continue
(ii) break
(iii) pass
(iv) return

34. What will be the output of the following Python code?


def FinalMarks(T1, T2):
return T1+T2
T1=150
T2=160
print(”Total marks scored are”,FinalMarks())
(i) 310 (ii) 0
(iii) None (iv) Error

35. Evaluate the following expression and identify the correct answer:
(24 * 3) – 2 % 4 + 8 // 3 + 3**4
(i) – 9 (ii) 153
(iii) 70 (iv) 152

36. What will be the output of the following code?


def simple_interest(p,r,t=2):
return p *r*t
SI= simple_interest(10000,0.2)
print(SI,simple_interest(50000,0.3,3))
(i) 45000.0 45000.0
(ii) 45000.0 4000
(iii) 4000.0
(iv) 4000.0
4000.0

37. What will be the output of the following code?

number1 = 100

def funct1(x):

global number1

number1 = 200

number1 = number1**x

print(number1)
funct1(2)
print(number1)
(i) 200 (ii) 100 (iii) 100 (iv) 200
40000 10000 40000 10000
38. What will be the output of the following code?

import random
color = ['Red', 'Orange', 'Yellow', 'Black', 'Cyan']
for c in range(len(color)):
p = random.randint(2,4)
print(color[p],end='$')
(i) Red$Red$Cyan$Orange$Yellow$
(ii) Cyan$Black$Black$Cyan$Yellow$
(iii) Black$Red$Black$Red$Black$
(iv) Black$Orange$Yellow$Black$Black$
39. What is the output of the following code snippet?
def flipnumber(L,y):
for i in range(y):
if L[i]%3==0:
L[i]**=3
if L[i]%2==0:
L[i]**=2
L=[3,2,4,8,9]
flipnumber(L,5)
for i in L:
print(i,end='#')
(i) 9#2#8#16#81#
(ii) 27#4#16#64#729#
(iii) 9#8#16#64#729#
(iv) 27#8#16#81#729#
40. Consider a file ‘quote.txt’

If you’ll look at what you have in life,


you’ll always have more.
If you look at what you don’t have in life,
You’ll never have enough.

What will be the output of the following code?


fileobj = open(“quote.txt”, ‘r’)
R1 = len(fileobj.readline().split())
R2= fileobj.readline()
R3 = fileobj.readline()
R4 = fileobj.read(12)
print(R1)
print(R4)
(i) 9 (ii) 37 (iii) 9 (iv) 27
you’ll never have enough. If you look you’ll never
41. What is the output of the following code?

Text = 'Happy hour12-3'


L= ""
for i in range(len(Text)):
if Text[i].isupper():
L=L+Text[i].lower()
elif Text[i].islower():
L=L+Text[i].upper()
elif Text[i].isdigit():
L=L+(Text[i]*2)
else:
L=L+'#'
print(L)
(i) hAPPY#HOUR1122#33
(ii) Happy#hOUR12#3
(iii) hAPPY#HOUR112233
(iv) Happy Hour11 22 33 #

42. Suppose content of ‘mytext.txt’ file is:


The key to success is to focus on goals, not obstacles.

What will be the output of the following code?


file = open(“mytext.txt”, ‘r’)
txt = file.read()
print(file.read(10))
(i) The key to (ii) obstacles.
(iii) Error (iv) No Output
43. Suppose the content of ‘moral.txt’ is:

Sometimes we’re tested not to show our weaknesses but to discover our
strengths.

What will be the output of the following code?


file = open(“moral.txt”)
line = file.read()
word = line.split()
for w in word:
if len(w)>8:
print(w)
file.close()
(i) Sometimes
weaknesses
discover
strengths
(ii) sometimes
tested
weaknesses
strengths
(iii) sometimes
weaknesses
strengths
(iv) tested

44. What will be the output of the following code?

def Sum():

global p
p=p+7**2

print(p, end= '#')

p = 10

print(p,end= '@')
Sum()
print(p)

(i) 10@59#59
(ii) 59@10#59

(iii) 59@59#10

(iv) 10@10#10

45. What will be the output of the following code if the contents of the
file ‘File1.txt’ are:
String may refer to

fileobj = open(“File.txt”,’w’)
fileobj.write(“Letters\n”)
fileobj.write(“Numbers\n”)
fileobj.write(“Special characters”)
fileobj.close()

fileobj = open(“File.txt”,’r’)
print(fileobj.read()
fileobj.close()
(i) Special Characters
(ii) letters
(iii) String may refer to
Letters
Numbers
Special Characters
(iv) Letters
Numbers
Special Characters

46. Consider the content of ‘rhyme.txt’ file is:


Head, shoulders, knees and toes,
Knees and toes.
Head, shoulders, knees and toes,
Knees and toes.
And eyes, and ears, and mouth, and nose.
Head, shoulders, knees and toes,
Knees and toes.
What will be the output of the following code?
fileobj=open(‘rhyme.txt','r')
count = 0
l=fileobj.readlines()
for i in l:
if(i[0]=='H'):
count=count+1
print(count)
fileobj.close()
(i) 3 (ii) 6
(iii) 2 (iv) 1

47. Consider the following directory structure:

Admin
Question Paper
First Term Second Term Final

Result1.xlsx Result2.xlsx FinalResult1.xlsx

There are three directories under root directory ‘Admin’. The current
working directory is Final. Identify
the relative path name for file ‘Result1.xlsx’.
(i) .\Result1.xlsx (ii) Admin\Final\First Term\Result1.xlsx
(iii) ..\First Term\Result1.xlsx (iv) First Term\Result1.xlsx
48. The readlines() function returns:
(i) A list of integers (ii) String
(iii) A list of single characters (iv) A list of strings
49. What will be the output of the following code snippet?
Tup1=(9,3,5,[1,2,3],8)
Tup1[3][1]=10
print(Tup1)
(i) Error (ii) (9, 3, 5, [1, 10, 3], 8)
(iii) (9, 3, 5, [1, 10, 2, 3], 8) (iv) (3, 3, 3, [1, 10, 3], 10)

Section C
Case Study Based Questions
This section consists of 6 Questions (50 to 55). Attempt any 5 questions.

Rashi is learning Python in preparation for an internship exam. She is


having a problem with one question
in which she has been assigned an incomplete Python code (given below) to
create a CSV file called
‘Employee.csv.’ Assist her in completing the code that generates the CSV
file with the given content.

Employee.csv
Empno,Name,Desig,Salary
E1,Bharti,Sales,30000
E2,Anuj,Marketing,50000
E3,Mudit,Accounts,64000
Incomplete Code:
______ #Statement 1
Csvfile = open(______, _______, newline=’’) #Statement 2
CsvObj = csv. ________( ________) #Statement 3
Rows = []
Fields = [‘Empnumber’, ‘EmpName’, ‘EmpDesig’, ‘EmpSalary’]
Rows.append(Fields)
for i in range(5):
Empno = input(“Enter Employee No:”)
Name = input(“Enter Employee Name:”)
Desig = input(“Enter Designation:”)
Salary = int(input(“Enter Salary:”))
records= [________________] #Statement 4
Rows.________(______) #Statement 5
_______._______(Rows)
#Statement 6
Csvfile.close()
50. Identify the relevant module to import in the blank space in line
marked as Statement 1.
(i) import pickle

(ii) import txt


(iv) import csv
(iii) import csv file
51.Identify the missing code for the blank space in line marked as
Statement 2.
(i) “Employee.txt”, ‘rb’

(ii) “Employee.csv”, ’wb’

(iii) “Employee.csv”, ’w’


(iv) “Employee.dat”, ’w’
52. Choose the function name (with argument) that should be used in the
blank space of line marked as
Statement 3.
(i) writer(“Employee.csv”) (ii) read(“Csvfile”)
(iii) writer(CsvObj) (iv) writer(Csvfile)
53. Identify the suitable code for blank space in line marked as Statement
4.
(i) Empno, Name, Desig, Salary (ii) “Empno, Name, Desig, Salary”
(iii) “Empno”, “Name”, “Desig”,”Salary” (iv) “Empno – Name- Desig – Salary”
54. Identify the suitable code for blank space in the line marked as
Statement 5.
(i) insert(data) (ii) delete(data)
(iii) append(records) (iv) addrows(records)

55. Identify the suitable code for blank space in the line marked as
Statement 6.
(i) Csvfile.load() (ii) CsvObj.dumprow()
(iii) Records.reader() (iv) CsvObj.writerows()

You might also like