You are on page 1of 6

------------------------------------------------------------------------------------------------------------------------------------------------

PERIODIC ASSESMENT-3

EVA World
GRADE - 11 AY
School SUBJECT – COMPUTER SCIENCE 2023-24

DATE: TIME DURATION - 1 HR MAX. MARKS: 30

GENERAL INSTRUCTIONS:
1. This question paper contains 4 sections
2. Section A contains (1- 10) question carrying 1 mark each
3. Section B contains (11- 15) question carrying 2 mark each
4. Section C contains (16-17) question carrying 3 mark each
5. Section D contains (18) question carrying 4 mark each
6. ALL QUESTIONS ARE COMPULSORY

--------------------------------------------------------------------------------------------------------
SECTION A

1. Which of the following unit is responsible for converting the data received 1
from the user into a computer understandable format?
(A) Output Unit
(B) Input Unit
(C) Memory Unit
(D) Arithmetic & Logic Unit
Answer:
Option (B) is correct
2. If the addition of a new key: value pair causes the size of the dictionary to 1
grow beyond its original size an error occurs. True or false?
Answer : False

3. SAY TRUE OR FALSE: 1


Python is case sensitive. (TRUE/ FALSE) [1]
Answer:
True
4. 1

1|Page
6. 1

7 1

8. (c) In Python, a tuple can contain elements of different types. 1

9. a) False 1

10 a) {1: ‘A’, 2: ‘B’, 3: ‘C’, 4: ‘D’} 1

Section B

11 Tuples are an important feature of Python. State some features of Tuples. 2


. Answer:
Some features of tuples are:

 Elements cannot be added to tuple.


 Tuples can store duplicate value.
 For a given index number, the element accessed is always the same.

12 Anuj wrote following code. How many times is the word “Welcome” printed 2

in the following code?


t = “i love python”
for ch in t[2:7]:
print (“Welcome”) [2]
Answer:
5 times

2|Page
13 Write a program to print the following pattern: 2
12345
1234
123
12
1
Answer:

14 Give an example to update single or multiple elements of lists 2


Answer:
You can update single or multiple elements of lists by giving the slice on the left-
hand side of the assignment operator, and you can add elements in a list with the
append () method. Following is a simple example:

List = [“Hey”, “Good Evening”]

print(“List before appending values is: “, List)

List.append(“Python”)

List.append(“Hey”)

print(“List after appending values is: ”, List)

Output:

3|Page
List before appending values is: [“Hey”, “Good Evening”]

List after appending values is: [“Hey”, “Good Evening”,


“Python”, “Hey”]

In the above example, we are appending ‘Python’ and ‘Hey’


values to the end of the List.

# !/user/bin/python
listl = [‘physics’, ‘chemistry’, 1997, 2000];
print “Value available at index 2 :”
print list[2];
list[2] = 2001;
print “New value available at index 2 :”
print list [2];
Note: append)) method is discussed in subsequent section.

When the above code is executed, it produces the following result:

Value available at index 2:


1997
New value available at index 2:
2001

15 Write the output of the following code. 2

A = [2, 4, 6, 8,10]
L = len (A)
S=o
for I in range (1, L, 2):
S + = A[I]
print “Sum=”, S

Answer:

Sum = 12
Justification:
A[1] = 4 step size = 2
A[3] = 8
S = 4 + 8 = 12

4|Page
16 write a program to find the largest and smallest number in a list without using 2
. loop.

a = input(“Enter a list”)
print(“ The list is: ”, a)
mx = max(a)
mn = min(a)
print(“ Maximum number in the list “, mx)
print(“ Minimum number in the list”, mn)
Section C

17 Consider the following code and then answer the question that follow: 3

myDict = { ‘a’:27,’b’: 43,’c’:25,’d’:30}


valA=’ ‘
for i in myDict:
if i >valA
valA = i
valB = myDict[i]
print(valA) #Line 1
print(valB) #Line 2
print(30 in myDict) #Line 3
myLst = list(myDict.items())
myLst.sort() #Line 4
print(myLst[-1]) #Line 5
I. What output does Line 1 produce?
II. What output does Line 2 produce?
III. What output does Line 3 produce?
IV. What output does Line 4 produce?
V. What output does Line 5 produce?
Answer: (i) d
(ii) 30
(iii) False
(iv) error
(v) error
18 3

Section D

19 Consider the following dictionary stateCapital: 4


​
stateCapital =
{"AndhraPradesh":"Hyderabad","Bihar":"Patna","Maharashtra":"Mum
bai", "Rajasthan":"Jaipur"}
Find the output of the following statements:

i. print(stateCapital.get("Bihar"))
ii. print(stateCapital.keys())
iii. print(stateCapital.values())

5|Page
iv. print(stateCapital.items())
v. print(len(stateCapital))
vi. print("Maharashtra" in stateCapital)
vii. print(stateCapital.get("Assam"))
viii. del stateCapital["Andhra Pradesh"]
print(stateCapital)

ANSWER:

i. Patna: 'get()' function returns the value corresponding to the


key passed as an argument.
ii. dict_keys(['AndhraPradesh', 'Bihar',
'Maharashtra', 'Rajasthan']): 'keys()' function returns
the list of the keys in the dictionary.
iii. dict_values(['Hyderabad', 'Patna', 'Mumbai',
'Jaipur']): 'values()' function returns the list of the values in
the dictionary.
iv. dict_items([('AndhraPradesh', 'Hyderabad'),
('Bihar', 'Patna'), ('Maharashtra', 'Mumbai'),
('Rajasthan', 'Jaipur')]): 'items()' function returns
the list of tuples in key value pair.
v. 4: 'len()' functions return the length or number of key:value pairs
of the dictionary passed as the argument.
vi. True: 'in' is a membership operator which returns true if a key is
present in the dictionary.
vii. None: 'get()' function returns 'None' if the key is not present in
the dictionary.
viii. del stateCapital["Andhra Pradesh"] will return an error
as the key ‘Andhra Pradesh’ is not present in the dictionary.
(‘Andhra Pradesh’ and ‘AndhraPradesh’ are different). However, if
the key is present it will delete the key:value pair from the
dictionary. If the statement is del
stateCapital["AndhraPradesh"], print(stateCapital)
will then print the remaining key: value pair. {'Bihar':
'Patna', 'Maharashtra': 'Mumbai', 'Rajasthan':
'Jaipur'}

6|Page

You might also like