0% found this document useful (0 votes)
21 views2 pages

12 CS-1

The document is a worksheet for a Computer Science subject, aimed at students in grade XII, containing various programming exercises and questions related to Python. It includes tasks such as modifying dictionaries, manipulating lists, and writing functions to process data. Additionally, it tests understanding of Python syntax and operations through multiple-choice questions.
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)
21 views2 pages

12 CS-1

The document is a worksheet for a Computer Science subject, aimed at students in grade XII, containing various programming exercises and questions related to Python. It includes tasks such as modifying dictionaries, manipulating lists, and writing functions to process data. Additionally, it tests understanding of Python syntax and operations through multiple-choice questions.
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/ 2

BONNE ANNE PUBLIC SCHOOL

WORKSHEET-(XII)
SUBJECT: COMPUTER SCIENCE
(REVISION TOUR :-2)

1. 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'}
I. 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’)
II. 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)
III. 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’]

2. Identify the output of the following Python statements.


lst1 = [10, 15, 20, 25, 30]
lst1.insert( 3, 4)
lst1.insert( 2, 3)
print (lst1[-5])
a. 2 b. 3 c. 4 d. 20
3. Find the output of the following code:
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)
a. pYTHOn##@ b. pYTHOnN#@ c. pYTHOn#@ d. pYTHOnN@#

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


tup1 = (1,2,[1,2],3)
tup1[2][1]=3.14
print(tup1)
a. (1,2,[3.14,2],3) b. (1,2,[1,3.14],3) c. (1,2,[1,2],3.14) d. Error Message
5. Write a function INDEX_LIST(L), where L is the list of elements passed as argument to the function. The function returns another list named
‘indexList’ that stores the indices of all Non-Zero Elements of L. For example: If
L contains [12,4,0,11,0,56]
The indexList will have - [0,1,3,5]
6. Write a program to create a list M which contain the square of element of even numbers and cube of elements of odd numbers of the given list L.

e.g. L= [3, 4, 5, 6, 2]
Output: M [27, 16, 125, 36, 4]
7. Write a function ELEM_LIST(L), where L is the list of elements passed as argument to the
function. The function returns another list named ‘elemList’ that stores the indices of all EVEN Elements of L.
For example: If L contains [12,4,10,11,89,56]
The elemList will have - [12,4,10,56]
8. Write definition of a function that takes input a sentence and display the list of words that end with a lowercase vowel and list of words that end
with a lowercase consonant.

9. Write a program to count the frequency of elements in a list entered by user.

10. Which of the following will delete key-value pair for key=”Red” from a dictionary D?
a) delete D(“Red”) b) del d[“Red”] c) D.del[“Red”] d) del.d[“Red”]
11. You have the following code segment:
String1=”my”
String2=”work”
print(String1+String2.upper())
a) mywork b) MY Work c) my WORK d) My Work

You might also like