Delhi Public School Jammu: SAMPLE PAPER (2024-25) Class: XII Subject: Computer Science
Delhi Public School Jammu: SAMPLE PAPER (2024-25) Class: XII Subject: Computer Science
Delhi Public School Jammu: SAMPLE PAPER (2024-25) Class: XII Subject: Computer Science
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.
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)
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.
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.