Delhi Public School Jammu: SAMPLE PAPER (2024-25) Class: XII Subject: Computer Science

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

DELHI PUBLIC SCHOOL JAMMU

SAMPLE PAPER (2024-25)

Class: XII
Subject: Computer Science (083)

General Instructions :
1. Programming language used is Python.
2. Use appropriate variable names.
3. Indent your program appropriately.
4. All questions are compulsory.

Q1. Multiple choice questions.


1. Which of the following is a valid identifier:
i. 9type ii. _type iii. Same-type iv. True

2. Which of the following is a relational operator:


i. > ii. // iii. or iv. **

3. Which of the following is a logical operator:


i. + ii. /= iii. and iv. in

4. Identify the membership operator from the following:


i. in ii. not in iii. both i & ii iv. Only i

5. Which one is a arithmetic operator:


i. not ii. ** iii. both i & ii iv. Only ii

6. What will be the correct output of the statement : >>>4//3.0


i. 1 ii. 1.0 iii 1.3333 iv. None of the above

7. What will be the correct output of the statement : >>> 4+2**2*10


i. 18 ii. 80 iii. 44 iv. None of the above

8. Give the output of the following code:


>>> a,b=4,2
>>> a+b**2*10

i. 44 ii. 48 iii. 40 iv. 88

9. Give the output of the following code:


>>> a,b = 4,2.5
>>> a-b//2**2

i. 4.0 ii. 4 iii. 0 iv. None of the above

10. Give the output of the following code:


>>>a,b,c=1,2,3
>>> a//b**c+a-c*a
i. -2 ii. -2.0 iii. 2.0 iv. None of the above
11. If a=1,b=2 and c= 3 then which statement will give the output as : 2.0 from the following:
i. >>>a%b%c+1 ii. >>>a%b%c+1.0 iii. >>>a%b%c iv. a%b%c-
1

12. Which statement will give the output as : True from the following :
i. >>>not -5 ii. >>>not 5 iii. >>>not 0 iv.
>>>not(5-1)

13. Give the output of the following code:


>>>7*(8/(5//2))
i. 28 ii. 28.0 iii. 20 iv. 60

14. Give the output of the following code:


>>>import math
>>> math.ceil(1.03)+math.floor(1.03)
i. 3 ii. -3.0 iii. 3.0 iv. None of
the above

15. What will be the output of the following code:


>>>import math
>>>math.fabs(-5.03)
i. 5.0 ii. 5.03 iii. -5.03 iv . None of
the above

Q16. Match the columns:


if
>>>L=list(‘computer’)
Column A Column B

1. L[1:4] a. [‘t’,’e’,’r’]
2. L[3:] b. [‘o’,’m’,’p’]
3. L[-3:] c. [‘c’,’o’,’m’,’p’,’u’,’t’]
4. L[:-2] d. [‘p’,’u’,’t’,’e’,’r’]
5. >>>tuple([10,20,30]) e. >>> (10,20,30)
6. >>>(“Tea”,)* 3 f. >>> 2
7. >>>tuple(“Item”) g. >>> ('Tea', 'Tea', 'Tea')
8. >>>print(len(tuple([1,2]))) h. >>> ('I', 't', 'e', 'm')
9.max() i. will compute (x)1/2
10. sqrt(x) j. will return the largest value
Q17. Write the corresponding python expression for the following mathematical expression.
z=x/a-(b+d2 ) 2. A=a2 – b2
Q18. Write a Python program to insert a given number at a particular index in a string where both
the number and the index value are user input.
Q19. What is the output of the following?
x = "abcdef"
while i in x:
print(i, end=" ")
20. What is the output of the following?
d = {0: 'a', 1: 'b', 2: 'c'}
for i in d:
print(i)
Q21. What is the output when following code is executed ?
names1 = ['Amir', 'Bear', 'Charlton', 'Daman']
names2 = names1
names3 = names1[:]
names2[0] = 'Alice'
names3[1] = 'Bob'
sum = 0
for ls in (names1, names2, names3):
if ls[0] == 'Alice':
sum += 1
if ls[1] == 'Bob':
sum += 10
print sum
Q22.What is the difference between the following set of statements (a) and (b):
a) P = open(“practice.txt”,”r”) P.read(10)
b) with open(“practice.txt”, “r”) as P: x = P.read()

Q23. Write a command(s) to write the following lines to the text file named hello.txt. Assume that
the file is opened in append mode. “ Welcome my class” “It is a fun place” “You will learn and
play”
Q24. Write a Python program to open the file hello.txt used in question no 6 in read mode to display its
contents. What will be the difference if the file was opened in write mode instead of append mode?

Q25. Write a program to accept string/sentences from the user till the user enters “END” to. Save the data
in a text file and then display only those sentences which begin with an uppercase alphabet.

Q26. Write a program to enter the following records in a binary file:


Item No integer
Item_Name string
Qty integer
Price float
Number of records to be entered should be accepted from the user. Read the fi le to display the records in
the following format:
Item No:
Item Name :
Quantity:
Price per item:
Amount: ( to be calculated as Price * Qty

Q27. What do you mean by a modem? Why is it used?

Q28. Explain the following devices: a) Switch b) Repeater c) Router d) Gateway e) NIC

Q29. Draw a network layout of star topology and bus topology connecting five computers.
Q30.

You might also like