Nothing Special   »   [go: up one dir, main page]

Set A

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

SET-A

DEEPIKA ENGLISH MEDIUM SCHOOL


SECTOR 05, ROURKELA
HALF YEARLY EXAMINATION-2023-24
CLASS: XII Maximum Marks:70 Marks
Time Allowed: 3 Hours
SUBJECT:COMPUTER SCIENCE (083)
General Instructions:
Atempt all questions. The question naner is divided into 4 sections -A, B,C and b 2
Section A, consist of 16 questions (1 16), Each question carries imarks.
Section B, consist of 12 questions (17. 28), Each question carries 2 marks.
Section C, consist of 5 questions (29- 33) Each question carries 3 marks.
Section D, consist of 3questions (34-36) Each question caries 5 marks.
SECTIONA-1 Marks
Q1.Find the invalid identifier from the following (1)
a) MyNameb/ True c 2ndName d) My_Name
Q2. Given a Tuple tup1= (10, 20, 30, 40, 50, 60, 70, 80, 90).
What wil be the output of print (tup1 [3:7:2)7 (1)
Q3. State True or False:
"In a Python program, if a continue statement is given in a nested loop, it terminates the (1)
execution ofall loops in one go." F
Q4.Name the Python Library modules which need to be imported to invoke the following functions:
9math
() sin) (ii) randint 0 (1)
Q5. What type will be printed when the following code executes?
aTuple = ("Orange")
print type(aTuple)
a. listb, tuplec. arrayd. str
Q6. Let list =[a', b', 'c. 'd, 'e, r (1)

Find a) list[1:3] b) t[:4]


Q7. Define dictionary with an examp1. (1)
(1)
Q8. Write the syntax for list comprehension.
Q9.Which of the following is the use of function in python? (1)

a/Functions are reusable pieces of programs


b) Functions don't provide better modularity for your application
c) you can't also create your own functions
d) All of the mentioned
Q10.Which of the following is the use of id) function in python? (1)
dreturns the identity of the objectb) Every object doesn't have a unique id
c) Allof the mentionedd) None of the mentioned
Q1IUser defined function uses . . . keyword (1)
Q12. Select all the parts that are absolutely needed to create and call a runcuos
(1)
a). function header (including the definition and the name)b) function bocy
c) function call YAll of these
Q13..Which of the following file types can be onened with notepad as well as ms excel? (1)
a. Text Files b. Binary Files CSV Files d. None of these
Q14.Every file has its own identity associated with it. Which is known as (1)
a. icon bX exten_ion c. format d. file type
Q15.Assertion(A):When a function is defined with a list of parameters with a function name in the funcion
header.It is known as parameterized function.
Reason (R): Anon-parameterised function does not include parameters with the function namein the
Tunction header.Thus the parenthesis remains empty and no arquments are passed while calling ne
function.
based on the above assertion and reasoning choose an appropriate statement from the options given
below:
(a) Both A and R are true and R is the correct
explanation of A.
Both A and R are true and R is not the correct explanation of A.
(c) A is true but R is false.

(d) A is false but R is true.

(e) Both A and R are false. (1)


Q16.. Assertion(A): The binary files are also a type of text files where data are stored in the fom of texts.
Reason (R): The binary files data in terms of binary values ie 0 and 1 .They are directly understood by the
computer and brought into operations without using any language translator.
Based on the above assertion and reasoning choose an appropriate statement from the options given
below:
(a) Both A and R are true and R is the correct explanation of A.
Both A and R are true and R is not the correct explanation of A.
(c) A is true but R is false.

(d) A is false but R is true.


(e) Both Aand R are false. (1)

SECTIONB-2 Marks
Q17.Mention any 4 list methods.(2)
Q18. What do you meant by mutability and immutability? (2)
Q19.Add a pair of parentheses to each expression sothat it evaluates to True. (2)
a) 0-1=-2)
b) 2+3==4)+ 5==7
Q20. What will be the output of the following statements?
i.)list1 =[12,32,65,26,8Q,10] (2)
2
list1.sort()
print(list1)
)list1 =[12,32,65,26,80,10]
sorted(list1)
print(list1)
Q21.Rewrite the following code in python after removing all syntr eiror(s). Underline each (2)
correction done in the code.

Num=-int(rawinput("Number:")
sum=0
for iin range(10,Num,3)
Sumt=1
if i%2-0:
print(i*2)
Else:
print(i"3 print Sum)

Q22.Find the output of the following (2)


x="one"
y="two"
c=0
while c<len(x):
print(x{c],y[C])
CHC+1
Q23What will be the output of the following code? (2)
import random
List-["Delhi","Mumbai","Chennai","Kolkata"]
for yin range(4):
X*random.randint(1,3)
print(List[x],end="#")
a Delhi#Mumbai#Chennai#Kolkata#
b Mumbai#Chennai#Kolkata#Mumbait#
C Mumbai# Mumbai #Mumbai # Delhi#
d Mumbai# Mumbai #Chennai # Mumbai

Q24. What is the output of the following code snippet? (2)


de fChangeVal (M, N) :
for i in range (N) :
if M[ij]%5 == 0:
M[i] //=5
if M[i]%3 == 0:
M[i]//=3
L= (25,8,75,12]
ChangeVal (L, 4 )
for i in L:
print (i, end="")
Q25.Find the output of the following code: (2)
Name="PythoN3.1"
R=""
for x in range (len (Name) ) :
if Name[x].isupper():
R=R+Name(x].lower()
elif Name (x] .islower () :
R=R+Name [x] .upper ()
elif Name [x] .isdigit () :
R=R+Name [x-1]
else:
R=R+"#"
print (R)
Q26..Suppose content of Myfile.txt' is (2
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
What willbe 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 countt= 1
print(line_count)
myfile.close0(2)
Q27. Explain open() function with its syntax in detail.
Q28.List out the basic file modes available in python.(2)
SECTIONC-3 Marks
Q29. Writea program using a user definedfunction myMean( to calculate the meanof floating
values stored in a list. 3)

Q30. Write a program using user definedfunction that accepts an integer andincrements the
value by 5. Also displaythe id of argument (before function call), id of parameter before
increment andafter increment. (3)
Q31. Define pickling in Python. Explain serialization anddeserialization of Python object. (3)
Q32. Write totheopenthe
file mode that willbe used for opening thefollowing files. Also, write the Pyhon
following files: (3)
statements
a) a text file "example.txt" in both read and write mode
b) a binary file bfile.dat" in write mode
c) a text file try.txt" in append and read
mode
hello.txt. Assume that
Q33. Wrte a command(s) to write the following lines to thetext file named
(3)
the file is openedin append mode.
" Welcome my class"
"It is a fun place"
"You will learn and play"

SECTIOND-5 Marks
vowels (5)
Q34Write a program using a function to accept characters in a list then find and display
present in the list.

(5)
Q35. Write a program to enter the following records in a binaryfile:
Item No integer
Item Name string
Qty integer
Price float
Number of records to be entered should be acceptedfrom the user. Read the file to display the
records in thefollowing format:
Item No:
Item Name:
Quantity:
Price per item:
Amount: ( to be calculated as Price * Qty)

Q36.Aman t, a student of class 12th, is learning CSV File Module in Python. During examination, he has been
assigned an incomplete python code (shown below) to create a CSV File 'Student.csv' (content shown below).
Help him in completing the code which creates the desired CSVFile. (5)
CSV File
1,AKSHAY,XI|A
2,ABHISHEK, XII,A
3,ARVIND,XII|A
4,RAVIXIA
5,ASHISHXII,A
Incomplete Code
import #Statement-1
fn = open newline=")#Statement-2
stuwriter = csv. #Statement-3
data =D
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:")
5
rec = L #Statement-4
data.append(rec)
stuwriter. (data) #Statement-5
fh.close()
Dldentify the suitable code for blank space in line marked as Statemen
a) csv file
b) CSV
gésv
d) Csv
i. )ldentify the missing code for blank space in line marked as Statement-2?
a) "School.csv""w
bYStudent.csv' "w
Student.csv""
d) "School.csv","
ii.) Choose the function name (with argument) that should be
used in the blank
space of line marked as Statement-3
a) reader(fh)
b) reader(MyFile)
writer(fh )
d) writer(MyFile)
iv) ldentify the suitable code for blank space in line
marked as Statement4.
,arROLL 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?

a) dump()
b) load()
c) writerows()
gwriterow()

You might also like