0% found this document useful (0 votes)
20 views7 pages

Ms 2

Uploaded by

duh.compwork
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)
20 views7 pages

Ms 2

Uploaded by

duh.compwork
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/ 7

Delhi Public School, Gandhinagar

Half Yearly Examination (2023-24)


Class: XI Computer Science (083) Date: 20.09.2023
Time: 3 Hours (Set-1: Answer Key) M. Marks: 70

Name: _______________________________ Sec: _________ Roll No.: ________

SECTION – A
1. a) Generates a random floating number in the range 60 to 100 and displays its nearest 1
higher integer
(1 mark for the correct answer)
2. a) 1
<class 'str'>
<class 'int'>
<class 'bool'>
(1 mark for the correct answer)
3. b) TypeError 1
(1 mark for the correct answer)
4. c) fruit = 'banana' 1
(1 mark for the correct answer)
5. a) Interactive mode 1
(1 mark for the correct answer)
6. c) == 1
(1 mark for the correct answer)
7. d) average() 1
(1 mark for the correct answer)
8. a) list 1
(1 mark for the correct answer)
9. a) '\n' (newline) 1
(1 mark for the correct answer)
10. b) Statement 4 1
(1 mark for the correct answer)
11. d) 1
hellooswal
hellohellooswal

Page 1 of 7
(1 mark for the correct answer)
12. c) 3 1
(1 mark for the correct answer)
13. a) "KV"+"KDML" % 2 1
(1 mark for the correct answer)
14. b) range(0,3) 1
(1 mark for the correct answer)
15. c) Sum= 12 1
(1 mark for the correct answer)
16. a) 1
True
False
[['are', 'going'], 'to']
(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. c) 1
(1 mark for the correct answer)
18. a) 1
(1 mark for the correct answer)
SECTION – B
19. i) A group of statements that are part of another statement or a function is called a block or 2
suite in Python. Python uses indentation to create blocks of code. Statements at the same
indentation level are part of the same block/suite. E.g. if, for are block or suite statement
(1 mark for the correct explanation)
ii) capitalize()
The method capitalize() returns a copy of the string with only its first character capitalized.
Example
str = "this is string example....wow!!!"
print(str.capitalize())
result: This is string example....wow!!!
(1 mark for the correct explaination/example)
20. for name in ['amar','shveta','parag']: 2
if name[0] == "S":

Page 2 of 7
print(name)
( ½ mark for each correct identification of error)
21. string=input("Enter a string:") 2
lstword=string.split()
cnt=0
for word in lstword:
if word[0] in 'hH':
cnt+=1
print("Number of words starting with H:",cnt)
( ½ mark for input/output, ½ mark for split()
½ mark for loop, ½ mark for if condition)
OR
import random
hours=random.randint(0,23)
mins=random.randint(0,59)
seconds=random.randint(0,59)
lst=[str(hours),str(mins),str(seconds)]
time=":".join(lst)
print("Random time:",time)
( ½ mark for importing library, ½ mark for generating random values
1 mark for combining random values and generating time)
22. [500, 600, 35, 45, 35, 45] 2
[500, 600, 35, 45]
3
[35, 45, 35, 45]
( ½ mark for each correct line of output)
23. i) The position of 'in' at: 6 2
(1 mark for the correct answer)
ii) ['bo', 'rd ex', 'm']
(1 mark for the correct answer)
24. ALGORITHM: 2
STEP 1 : START
STEP 2 : Input a number N
STEP 3: Compute Remainder as N divided by 3
STEP 4 : If (Remainder=0) GOTO STEP 5 ELSE STEP 6
STEP 5 : Print "Divisible by 3" GOTO STEP 7
STEP 6 : Print "Not divisible by 3" GOTO STEP 8
STEP 7 : END

Page 3 of 7
(1 mark for any 3 correct steps, 2 marks for all correct steps)
25. COMPUTERddd0sci 2
(2 marks for the correct output)
SECTION – C
26. i) ['a', 'z', 'p', 'm'] 3
m
( ½ mark for each correct line of output)
ii) Physics
Compulsory
Chemistry
Compulsory
Mathematics
Optional
(1 mark for the correct output)
iii) -12.5
(1 mark for the correct output)
27. i) rstrip() 3
ii) isalnum()
iii) trim()
iv) split()
v) sort(reverse=True)
vi) pop()
(½ mark for each correct function)
28. N1=int(input("Enter Value: ")) 3
N2=int(input("Enter Value: "))
HCF=1
if N1>N2:
L=N1
S=N2
else:
L=N2
S=N1
if L%S==0:
HCF=S
else:
I=S//2
while I>0:
if L%I==0 and S%I==0:

Page 4 of 7
HCF=I
break
I-=1
print("hcf=",HCF)
( ½ mark for i/p and o/p, ½ mark for finding the greater number,
1 mark for loop, 1 mark for condition)
OR
n=int(input("Enter number of lines"))
for i in range(1,n+1):
sym=1
for j in range(1,i+1):
print(sym,end=" ")
sym+=2
print(t,end=" ")
(1 mark for the outer loop and its body, 1 mark for the inner loop and its body,
½ mark each for proper input/output)
29. i) == is comparison operator whereas = is assignment operator. 3
(1 mark for the correct difference example)
ii) An infinite loop is one whose terminating condition is either missing or is not reachable, thus
the body of the loop keeps repeating endlessly.
(1 mark for the correct answer)
iii) Identifiers play a key role in programs. They are the names given to different parts of the
program like a variable(s), object(s), function(s), etc. in Python or any correct answer
(1 mark for correct definition)
30. x=int(input("Enter no. of days for A to complete job:")) 3
y=int(input("Enter no. of days for B to complete job:"))
z=int(input("Enter no. of days for C to complete job:"))
ndays=xyz/(xy+yz+zx)
print("No. of days to complete the job if done together:",round(ndays,1))
(1 mark for i/p, 1 mark for calculation, 1 mark for o/p with round())
SECTION – D

31. i) a) 2
False
5
b)
True
5
(1 mark for each correct answer)

Page 5 of 7
ii) 5 2
0
4
1
( ½ mark for each correct answer)
32. import math 4
a=int(input("Enter Side1:"))
b=int(input("Enter Side2:"))
c=int(input("Enter Side3:"))
if a+b>c and b+c>a and a+c>b:
print("Triangle Possible")
if a==b and b==c:
print("Equilateral Triangle")
elif a==b or b==c or a==c:
print("Isosceles Triangle")
else:
print("Scalene Triangle")
s=(a+b+c)/2
area=math.sqrt(s*(s-a)*(s-b)*(s-c))
print("area=",area)
else:
print("Triangle Not Possible")
(1 mark for input/output, 1 mark for checking condition for a triangle,
1 mark for evaluating triangle type, 1 mark for calculating area)
SECTION – E
33. i) import math 1
ii) int( input('Enter a number:')) 1
iii) math.sqrt(n) 1
iv) range(2,m//2+1) 1
v) 8 which is a square root of 64 is not a Prime number. 1
(1 mark for each correct answer)
34. i) A keyword is a special word that has a special meaning the purpose in the programming 5
language. Keywords are the reserved word like if, else, for, etc
Literals means constants i.e. the data items that never change their value during the
program run. Python allows different types of literals like String literals, Numeric literals,
Boolean literals, and Special literals. E.g. "Hello"-String literal, True-Boolean literal
(1 mark each for the correct explaination, 1 mark for correct example)
ii) Lst=eval(input("Enter a list:"))

Page 6 of 7
M=int(input("Enter M:"))
N=int(input("Enter N:"))
print("Original List:",Lst)
NewLst=[]
for I in Lst:
if I%M==0 and I%N==0:
NewLst.append(I)
print("New List:",NewLst)
(1 mark for i/p and o/p, 1 mark for initializing NewLst and loop,
1 mark for condition and append())
OR
Lst1=eval(input("Enter first list:"))
Lst2=eval(input("Enter second list:"))
if len(Lst1)==len(Lst2):
for i in range(len(Lst1)):
if Lst1[i] != Lst2[i]:
print("List contents differing at index:",i)
break
else:
print("Lists contents are same")
( 1 mark for i/p and o/p, ½ mark for if condition, ½ mark for loop
1 mark for loop if condition and use of break)
35. i) Syntax errors occur when the rules of a programming language are misused or violated. 1
e.g. X=<Y*Z #results in error as =< is not a relational operator
(1 mark for the correct explanation/example)
ii) a) gives error as upper() function works with string not lists 1
d) gives error as L2[1:2] generates a slice in the form of a nested list i.e. [["is","another"]]
and L2[1:2][0] generates a list ["is","another"] and lower() function works only with
string, not lists
(1 mark for the correct options, 1 mark for the reason)
iii) False 1
True (½ mark for each correct output)
iv) [1, 4, 2, 6] 1
[5, 6]
( ½ mark for each correct line of output)
v) 15
14 50
(1 mark for each correct answer)

Page 7 of 7

You might also like