Set A
Set A
Set A
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)
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()