AKR ACADEMY SCHOOL (CBSE)
PERIODIC TEST-2 (JULY)
GRADE:XII COMPUTER SCIENCE(083) MARKS:40
I.ANSWER THE FOLLOWING 14*1=14
1. State True or False.
Comments are not executed by interpreter
2. Which of the following is not a sequential datatype in Python ?
(a) Dictionary (b) String (c) List (d) Tuple
3. Given the following dictionary
Day={1:"Monday", 2: "Tuesday", 3: "Wednesday"}
Which statement will return "Tuesday".
(a) Day.pop() (b) Day.pop(2) (c) Day.pop(1) (d) Day.pop("Tuesday")
4. Consider the given expression : 73 and not 10==10 or 17>4
Which of the following will be the correct output if the given expression is evaluated ?
(a) True (b) False (c) NONE (d) N
5. Select the correct output of the code :
S="Amrit Mahotsav @ 75"
A=S.split(" ",2)
print(A)
(a) ('Amrit', 'Mahotsav', '@', '75') (b) ['Amrit', 'Mahotsav', '@ 75']
(c) ('Amrit', 'Mahotsav', '@ 75') (d) ['Amrit', 'Mahotsav', '@', '75']
6. Fill in the blank : ___________ is not a valid built-in function for list manipulations.
(a) count() (b) length() (c) append() (d) extend()
7. Which of the following is an example of identity operators of Python ?
(a) is (b) on (c) in (d) not in
8. Which of the following statement(s) would give an error after executing the following code ?
S="Happy" # Statement 1
print(S*2) # Statement 2
S+="Independence" # Statement 3
S.append("Day") # Statement 4
print(S) # Statement 5
(a) Statement 2 (b) Statement 3 (c) Statement 4 (d) Statement 3 and 4
9. What will the following expression be evaluated to in Python ?
print(6/3 + 4**3//8 4)
(a) 6.5 (b) 4.0 (c) 6.0 (d) 4
10. Which of the following functions is a valid built-in function for both list and dictionary datatype ?
(a) items() (b) len() (c) update() (d) values()
11. fetchone() method fetches only one row in a ResultSet and returns a __________.
(a) Tuple (b) List (c) Dictionary (d) String
12. Consider the following code and answer the questions that follow:
Book={1:'Thriller', 2:'Mystery', 3:'Crime', 4:'Children Stories'}
Library ={'5':'Madras Diaries','6':'Malgudi Days'}
Ramesh needs to change the title in the dictionary book from ‘Crime’ to ‘Crime Thriller’.
He has written the following command: Book[‘Crime’]=’Crime Thriller’ But he is not getting the answer.
Help him choose the correct command:
a. Book[2]=’Crime Thriller’ b. Book[3]=’Crime Thriller’
c. Book[2]=(’Crime Thriller’) d. Book[3] =(‘Crime Thriller’)
13. What will be the output of the following line of code:
print(list(Library))
a. [‘5’,’Madras Diaries’,’6’,’Malgudi Days’] b. (‘5’,’Madras Diaries’,’6’,’Malgudi Days’)
c. [’Madras Diaries’,’Malgudi Days’] d. [‘5’,’6’]
14. The command to merge the dictionary Book with Library the command would be:
a. d=Book+Library b. print(Book+Library) c. Book.update(Library) d. Library.update(Book)
II.ANSWER THE FOLLOWING 7*2=14
15. Write the Python statement for each of the following tasks using BUILT-IN functions/methods only:
(i) To insert an element 200 at the third position, in the list L1.
(ii) To check whether a string named, message ends with a full stop / period or not.
16. Predict the output of the following code:
17. The code given below accepts a number as an argument and returns the reverse number. Observe the
following code carefully and rewrite it after removing all syntax and logical errors. Underline all the
corrections made.
18. (a) Given is a Python string declaration :
NAME = "Learning Python is Fun"
Write the output of :
print(NAME[-5:-10:-1])
(b) Write the output of the code given below :
dict1={1:["Rohit",20], 2:["Siya",90]}
dict2={1:["Rahul",95], 5:["Rajan",80]}
dict1.update(dict2)
print(dict1.values())
19. Write a function search_replace() in Python which accepts a list L of numbers and a number to be searched.
If the number exists, it is replaced by 0 and if the number does not exist, an appropriate message is
displayed.
Example :
L = [10,20,30,10,40]
Number to be searched = 10
List after replacement :
L = [0,20,30,0,40]
20. What possible output(s) are expected to be displayed on screen at the time of execution of the following
code ?
import random
S=["Pen","Pencil","Eraser","Bag","Book"]
for i in range (1,2):
f=random.randint(i,3)
s=random.randint(i+1,4)
print(S[f],S[s],sep=":")
Options :
(I) Pencil:Book (II) Pencil:Book Eraser:Bag (III) Pen:Book Bag:Book (IV) Bag:Eraser
21. Predict the output of the code given below :
III.ANSWER THE FOLLOWING 4*3=12
22. Sartaj has created a table named Student in MYSQL database, SCHOOL:
rno(Roll number )- integer
name(Name) – string
DOB (Date of birth) – Date
Fee – float
Note the following to establish connectivity between Python and MySQL:
Username – root
Password – tiger
Host – localhost
Sartaj, now wants to display the records of students whose fee is more than 5000. Help Sartaj to write the
program in Python
23. Consider the following table traders with following fields
Tcode Tname city
T01 Electronic sales Mumbai
T02 Busy store Corp Delhi
T03 Disp house Inc Chennai
Write Python code to display the names of those traders who are either from Delhi or from Mumbai
24. Predict the output:
25. Predict the output of the Python code given below: