0% found this document useful (0 votes)
3 views6 pages

CS Xii

The document contains a revision sheet for Class XII Computer Science with multiple-choice questions covering various topics such as Python programming, file handling, and data types. Each question provides options for answers, focusing on practical coding scenarios and theoretical concepts. The document serves as a study guide for students preparing for their examinations.

Uploaded by

nishichauhan8081
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)
3 views6 pages

CS Xii

The document contains a revision sheet for Class XII Computer Science with multiple-choice questions covering various topics such as Python programming, file handling, and data types. Each question provides options for answers, focusing on practical coding scenarios and theoretical concepts. The document serves as a study guide for students preparing for their examinations.

Uploaded by

nishichauhan8081
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/ 6

REVISION SHEET -1(2025-26)

CLASS-XII
SUBJECT: COMPUTER SCIENCE (083)

1. Select the correct option to extract [23,2,9,75] from [6,23,3,2,0,9,8,75].


a) print(list1[1:7:2]) b)print(list1[0:7:2]) c)print(list1[1:8:2]) d)print(list1[0:8:2])

2. Which of the following operator cannot be used with string data type?
a) + b) * c) += d) **

3. Which of the following properly expresses the precedence of operators (using parentheses) in the
following expression:
5*3 > 10 and 4+6==11
a) ((5*3) > 10) and ((4+6) == 11) c) (5*(3 > 10)) and (4 + (6 == 11))
b) ((((5*3) > 10) and 4)+6) == 11 d) ((5*3) > (10 and (4+6))) == 11

4. What is the output of the functions shown below?


>>>min(max(False,-3,-4), 2,7)
a) 2 b) False c) -3 d) -4

5. Which is feature of python language?


a). cross platform b) Open source c). Case sensitive d). All of these

6. Look the code below and answer as directed.


Fn = open(“poem.txt , ____) #mode
print(Fn.read(5))
What should be the mode in the above statement?
a) w b) r c) r+ d) both b) & c)

7. Write a statement to send the file pointer to the end of file, consider FILE as file object.
a) FILE .seek(0) b) FILE .seek(0,1) c) FILE .seek(2,0) d) FILE .seek(0,2)
8. ________
File = open(‘a.csv’,”a”,newline=’’)
File.close()
Select the option to fill in the blank in above code to include the required module.
a) import CSV b) from csv import * c) import csv d) both b) & c)

9. Match the following:


1. Membership operator i. /
2. Identity operator ii. //
3. Float division iii. in
4. Integer division iv. is
Select the option that matches correct pair from above.
a) 1-iv,2-iii,3-ii,4-i b) 1-iv,2-ii,3-iii,4-i c) 1-iii,2-iv,3-ii,4-i d) 1-iii,2-iiv,3-i,4-ii

10. Identify the correct option to delete the last value 25 from the list
L=[22,44,66,[80,20],15,25]
a) L.pop() b) L.pop(-1) c) L.remove(25) d) All of these

1
11. The order of passing arguments in a function call can be changed through ______ argument.
a) positional b) keyword c) named d) both b) & c)

12. What is the output produced by the following code –


d1={‘a’:[6,8],”b”:(1,3)}
print(list(d1.items( )))
a) { (‘a’,(1,3)) , (‘b’,[6,8] } b) [ (‘a’,[6,8]), (‘b’,(1,3)) ]
c) [(6,8),(1,3)] d) (‘a’, “b”)

13. Give output of following:


>>>list(range(1,7,2))
a) [1,3,5,] b). [1,3,5,7] c). (1,3,5) d). {1,3,5}

14. _________ is used to include an empty statement in python.


a).pass b).None c).Null d).empty

15. What kind of data type is returned by split( )?


a) Tuple b)List c)String d) Integer

16. What will be the output of the following code?


>>>a1,a2=[1,2,3],[5,6]
>>>a1.extend(a2)
>>>a1
a) [5,6,1,2,3] b). [1,2,3,[5,6] ] c) [1,2,3] d). [1,2,3,5,6]

17. Which of the following is invalid tuple declaration?


a) t=(20) b) t=(20,) c) t=tuple(20) d) t=([20],)

18. How many times the following iteration will execute?


for k in range(10,2,-2):
print(‘2’*k,end=’’)
a) 4 b) 5 c) 6 (d) 3

19. If the content of the file “wish.txt” is – “Happy”, then what will be the content of the file after
executing the following statements –
f=open(“wish.txt”, ‘w’)
f.write(“Birthday”)
f.close()
a) Happy Birthday b)HappyBirthday c)Happy d)Birthday
20. Select the jump statements from the following:
a). continue b). break c). return d). All of these

21. Identify correct statement with respect to a function definition in a program.


a) Function header contains formal parameters. c) Function call receives actual parameters.
b) Function may or may not return any value. d) All of the mentioned above.

22. Which of the following functions is required to write data in a csv file?
a)writerow( ) b)writerows( ) c)writer( ) d)all of these

23. Select the appropriate option to read first 3 characters from a text file represented by FR object.
a) FR.read(3) b)FR.readline(3) c)FR.readline(2) d)both a) & b)

2
24. A csv file Info.csv contains following data about code and number of students enrolled in different
subjects and each row data is separated by tab stop.
83 CS 1123
65 IP 1098
302 HINDI 2500
Now select the correct option for code-1 in the following:.
import csv
with open(“Demo.txt”,”r”,newline=’’) as P:
Q=csv.reader(P,_______)#code 1
P.close()
a) delimiter=’/t’ b) delimiter=’\t’ c) delimiter=tab d) sep=’\t’

25. Select the option that gives output of following code:


>>>p=[9,7]
>>>q=p
>>>q[1]=77
>>>print(p,q)
a). [9,7] [9,77] b). [9,77] [9,77] c). [9,7] [9,7] d). None of these

26. Give the output of the following:


def test(a=909,b=4):
s=0
while a>0:
s=s+a%10
a=a//10
return s/b
x=23
print(test(x)+test())
a) 5.75 b) 1.25 c) 4.5 d) 4.75

27. Rajat is a class 12 student and he has created a text file named names.txt. He wants to display all
the names contained in the text file. He has written one of the following codes and succeeded in
getting the output. Guess which among the following option might have given the correct output:
a. names = open("names.txt", "r")
for line in names:
print(names)
b. names = open("names.txt", "r")
for line in names:
print("line")
c. names = open("names.txt", "r")
for line in names:
print(line)
d. names = open("names.txt", "r")
for names in line:
print(line)

28. Suppose content of 'Myfile.txt' is ‘India is a \ngreat country.’


What will be the output of the following code?
myfile = open("Myfile.txt")
x = myfile.readlines()
y = len(x)
print(y)
myfile.close()
3
a. 1 b. 2 c. 3 d. 4

29. Suppose content of 'Myfile.txt' is ‘Time and Tide wait for none’
What will be the output of the following code?
myfile = open("Myfile.txt")
p=0
x = myfile.read()
for y in x:
if y in ‘Tt’:
p=p+1
print(p)
myfile.close()
a. 2 b. 3 c.4 d. None

30. What output will following code generate?


def ABC(A):
print(A,end=’’)
print(ABC(‘hello’))
a). Nonehello b). hello c). helloNone d). Error
31. The following code prints the cube of a number. Write the missing statement.
a=3
def cube():
________ #missing statement
a**=3
cube( )
print(a)
a) a=1 b) Nothing will be written c) global a d) local a

32. What is the output of the code:


a=0
for i in range(4, 8):
if i % 2 == 0:
a=a+i
print(a)
a. 4 b. 8 c. 10 d. 18

33. Consider the following program. What is the correct flow of execution of statements?
1) def fun1(m, n):
2) c=m+n
3) print(c)
4) return c
5) x = 10
6) y = 20
7) fun1(x,y)
8) print(“OK”)
(a) 1,2,3,4,5,6,7,8 (b) 1,5,6,7,1,2,3,4,8 (c) 1,5,6,1,2,3,4,7,8 (d) 7,8,1,2,3,4,5,6

34. What output will following function returns? Select the correct option.
def result():
return 2-10*(10+6)//5%2**3**2
a)30 b)-30 c)-32 d)2.0

35. What will be the output of the following code?

4
X=100
def my_func(P=20, Q=30):
P+=10
Q = Q - 10
X=P+Q
return X
print(my_func(50),X)
a. 50 50 b. 50 100 c. 80 100 d. 80 80

36. Consider the tuple in python named NUM=(1,2,3).


What will be the value of DOUBLE, if -
>>> DOUBLE=NUM*2
(a) (2,4,6) (b) (1,1,2,2,3,3) (c) (1,2,3,1,2,3) (d) Error
37. What will be the output of the following code?
import random
List=["AAA","BBB","CCC","DDD"]
for y in range(4):
x = random.randint(1,3)
print(List[x],end="#")
a) AAA#BBB#CCC#DDD# c) BBB#CCC#DDD#DDD#
b) CCC# AAA #BBB # DDD# d) BBB# CCC #DDD # DDD
38. Find the output of the following code –
fp = open("sample.txt", "r")
fp.read(8)
print(fp.tell())
fp.close()
(a) 0 (b) 7 (c) 8 (d) 9
39. Whenever possible, what is the recommended way to ensure that a file object is properly closed
after usage? Select the best possible option.
(a) By using try block (b) Making sure that close() function is called.
(c) By using the with statement (d) It doesn’t matter
40. Which of the following command is used to open a file “c:\newfile.txt” in read and write mode
both?
(a) infile = open(“c:\ newfile.txt”, “r”) (b) infile = open(“c:\\ newfile.txt”, “r”)
(c) infile = open(file = “c:\ newfile.txt”, “r+”) (d) infile = open(file = “c:\\ newfile.txt”, “r+”)
41. To write the following data type to a csv file ___________ method is used .
p=[[‘a’,’b’],[‘1’,’2’]]
a)writelines( ) b)writerows( ) c)write( ) d)dump( )
42. Select the option that generate the correct output for following code:
import csv
def rt():
p=[ ]
a=open('sports.csv','w',newline='')
w=csv.writer(a)
d=['a']
w.writerows(d)
a.close()
def ct():
with open('sports.csv') as p:
k=csv.reader(p)
print(list(k))
rt()
ct()

5
a) [ ‘a’] b) ‘a’ c) [[‘a’]] d.any type
43. def Interest(p,c,t=2,r=0.09):
return p*t*r
Considering the above defined function ,which of following function call are legal.
1. Interest(p=1000,c=5)
2. Interest(r=0.05,5000,3)
3. Interest(500,t=2,r=0.05)
4. Interest(c=4,r=0.12,p=5000)
a). 1 , 2 and 4 b). 2 & 3 c). 1 &4 d). 3 & 4
44. Assertion (A): We can use a list as a key in a dictionary.
Reason(R): List is a mutable type and keys of dictionary must be an immutable type.
a) Both the A and R are true and R is the correct explanation for A
b) A is true and R is false and R is the correct explanation for A
c) A is false but the R is true and R is the correct explanation for A
d) Both the A and R are false
49.Krishna of class 12 is writing a program to input the details of games played at different venues
along with their prize money and store them in the csv file “games.csv” delimited with a ‘#’
character. As a programmer, help him to achieve the task.
import _________ # Line 1
f = open("games.csv","a",_________) # Line 2
fileWriter=csv.___________________ # Line 3
fileWriter.writerow(['GameName', 'PrizeMoney','Venue'])
while True:
gname = input("Enter Game Name :")
prize = int(input("Enter Prize Money :"))
venue = input("Enter Venue :")
record = __________________ # Line 4
fileWriter._________________ # Line 5
ans = input("Do u want to continue ? (y/n) :")
if ans!='y':
break
f.close()
Now select the appropriate option(i-iv) from the following questions.
(i) Fill in the blank in Line 1 to import appropriate module.
(a) pickle (b) csv (c) math (d) random
(ii) Fill in the blank in Line 3 to create writer object with separator as "#".
(a) writer(f,separator='#') (b) writer(f,delimiter='#')
(c) writer(delimiter='#',f) (d) writer(separator='#',f)
(iii) Fill in the blank in Line 2 to remove EOL character
(a) newline='\r\n' (b) newline='\n' (c) remove='EOL' (d) newline=""
(iv) Fill in the blank in Line 4 to store the input data in a List named record.
(a) record.append([gname,prize,venue] ) (b) append([gname,prize,venue])
(c) [gname,prize,venue] (d) (gname,prize,venue)
(v) Write the missing code in Line 5 to write the value of variable record to a CSV
File ‘games.csv’.
50. Write statement using built-in methods/functions to carry out following:
i) To know the frequency of E element in L list.
ii) To remove a given element E from a list L.
iii) To merge d1 dictionary with d2 dictionary.
iv) To store all the words of S string in a List L.
************************

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy