Delhi Public School, Gandhinagar Half Yearly Examination (2023-24) Computer Science (Set-2: Answer Key)
Delhi Public School, Gandhinagar Half Yearly Examination (2023-24) Computer Science (Set-2: Answer Key)
SECTION – A
1. c) 13 1
(1 mark for the correct answer)
2. b) 1
<class 'float'>
<class 'str'>
<class 'int'>
(1 mark for the correct answer)
3. d) IndexError 1
(1 mark for the correct answer)
4. d) {kendriya} 1
(1 mark for the correct answer)
5. b) Cross Platform 1
(1 mark for the correct answer)
6. a) 4 6 8 1
(1 mark for the correct answer)
7. d) math.sin(x)/math.cos(y)+math.exp(2*x)+math.pow(x+y,1/3) 1
(1 mark for the correct answer)
8. c) 1
1
5
(1 mark for the correct answer)
9. b) Total4 1
(1 mark for the correct answer)
10. b) Cold Cream 1
(1 mark for the correct answer)
11. c) ['My ', ' is ', ' for you'] 1
(1 mark for the correct answer)
Page 1 of 8
12. c) CD 1
(1 mark for the correct answer)
13. c) "PYTHON" + 10 1
(1 mark for the correct answer)
14. c) 1
for J in range(10,-1,-2):
print("X")
(1 mark for the correct answer)
15. d) [10, 8, 6, 4, 2] 1
(1 mark for the correct answer)
16. d) 1
['have', 'fun', 'with']
True
going
(1 mark for the correct answer)
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct
choice as
a) Both A and R are True and R is the correct explanation for A
b) Both A and R are True and R is not the correct explanation for A
c) A is True but R is False
d) A is False but R is True
17. d) 1
(1 mark for the correct answer)
18. b) 1
(1 mark for the correct answer)
SECTION – B
19. i) There are two membership operators in Python in and not in. 2
in: Evaluates to true if it finds an object in the specified sequence and false otherwise
not in: Evaluates to true if it does not find an object in the specified sequence and false
otherwise.
ii) title(): It returns a copy of the string with the first character of each word capitalized.
Example
str = "this is string example....wow!!!"
print(str.title())
result: This Is String Example....wow!!!
20. Weather='Raining' 2
Page 2 of 8
if Weather=='Sunny':
print("Wear sunblock')
elif Weather=='Snow':
print('Going Skiing')
else:
print('None of above')
( ½ mark for each correct identification of error)
Page 3 of 8
iv) False
( ½ mark for each correct output)
24. ALGORITHM: 2
STEP 1: START
STEP 2: Input sides of triangle, A, B, and C
STEP 3: Find the largest of three sides and store it in LargestSide. Take Side1 and Side2
as the remaining sides
STEP 4: Compute R=(Side12 +Side22)
STEP 5: If LargestSidexLargestSide= R GOTO STEP 6 ELSE STEP 7
STEP 6: Print “Right Angled Triangle” GOTO STEP 7
STEP 7: Print “Not a Right Angled Triangle.” GOTO STEP 8
STEP 8: END
( 1 mark for any four correct steps, 2 marks for all correct steps)
25. Model 2
Experiment
2021
XI
CS
Science
( 1 mark for any three correct lines of output,
2 marks for all correct lines of output)
SECTION – C
26. i) [1, 7, 2, 2, 6, 4, 9] 3
(1 mark for the correct output)
ii) apple
cherry
litchi
orange
(1 mark for the correct output)
iii) False
(1 mark for the correct output)
27. i) 'madam'.rfind('m') 3
ii) 'hello'.replace('o', '*')
iii) 'hectic'.lstrip('h')
iv) 'Revolution'.partition('t')
v) "ScHoOl".swapcase()
vi) 'S' in 'Schedule'
( ½ mark for each correct expression)
28. n=int(input("Enter a positive number:")) 3
Page 4 of 8
num=n+2
for i in range(2,num//2+1):
if num%i==0:
print("Composite")
break
else:
print("Prime")
(1 mark for i/p and o/p
1 mark for loop
1 mark for condition and use of break)
OR
n=int(input("Enter number of Terms:"))
x=int(input("Enter value of x:"))
sum=0
for i in range (1,n+1):
num=x**i
term=x/i
if i%2==1:
sum+=term
else:
sum-=term
print("Sum of series:",round(sum,2))
( ½ mark for input/output,
½ mark for loop,
1 mark for evaluating the term and adding it to sum)
29. i) Mutable types means those data types whose values can be changed at the time of 3
execution. Lists, Dictionaries, and Sets are mutable types in Python.
(1 mark for the correct answer)
ii) Python offers two jump statements to be used within loops to jump out of loop iterations
or to transfer the program control. e.g. break and continue statements.
(1 mark for the correct answer with an example)
iii) ord() returns the ASCII value of a given character.
ord('A') returns 65
(1 mark for the correct explanation)
30. qtf=int(input("Enter Quarterly Tuition Fee:")) 3
atc=int(input("Enter Annual Transport Charges:"))
amc=int(input("Enter Annual Mess Charges:"))
charges=qtf*4+105/100+atc*107.5/100+amc*110.25/100
print("Charges Payable for the entire year:",int(charges))
Page 5 of 8
(1 ½ mark for i/p and o/p
1 ½ mark for calculation of charges)
SECTION – D
Page 6 of 8
List[3]=99
v) print(List[::-1]) 1
34. i) The main difference between lists and a string is the fact that lists are mutable whereas 5
strings are immutable. A mutable data type means that a Python object of this type can be
modified.
In consecutive locations, strings store the individual characters while lists store the
references of its elements of different data types
(1 mark each for any two correct points of difference)
ii) val=eval(input("Enter a list:"))
print("Original List:", val)
s=len(val)
if s%2!=0:
s=s-1
for i in range(0,s,2):
val[i],val[i+1]=val[i+1],val[i]
print("List after swapping:",val)
(1 mark for i/p and o/p
1 mark for condition and loop
1 mark for swapping)
OR
mylst=eval(input("Enter a list:"))
high=mylst[0]
low=mylst[0]
cnt=0
s=0
for ele in mylst:
cnt+=1
if ele>high:
high=ele
if ele<low:
low=ele
s=s+ele
print("Highest:",high)
print("Lowest:",low)
print("Average:",s/cnt)
(1 mark for i/p and o/p
1 mark for initialization of variables and loop
1 mark for evaluating highest, lowest and average)
Page 7 of 8
35. i) An Error indicates serious problems that a reasonable application should not try to catch." 1
An Error is a bug or mistake in the code.
An Exception is an unexpected situation that may result in an abnormal termination of a
program. An exception indicates conditions that a reasonable application might want to
catch. Python uses try..catch blocks to handle an exception.
(1 mark for the correct point of difference)
ii) a) [['students','words'],'few'] 1
b) 'words'
( ½ mark for each correct output)
iii) hellohellohello 123 1
hellowworld 10
( ½ mark for each correct output)
iv) Mmin 1
y Py
(½ mark for each correct line of output)
v) Odd Balanced 1
(1 mark for the correct answer)
Page 8 of 8