You are on page 1of 5

Practice Paper

Class XII
Computer Science
TERM-I

M.M 25
Note : Attempt all questions, each question carry 1 mark.

Q 1. What is the output when following code is executed ?


names1 = ['Ashi', 'Bhumi', 'Charu', 'Diksha']
names2 = names1
names3 = names1[:]
names2[0] = 'Arti'
names3[1] = 'Bhanu'
sum = 0
for ls in (names1, names2, names3):
if ls[0] == 'Arti':
sum += 1
if ls[1] == 'Bhanu':
sum += 10
print (sum)

a) 11
b) 12
c) 21
d) 22

Q 2. What is the output of following?


a=(1,2,(4,5))
b=(1,2,(3,4))
print(a<b)

a) False
b) True
c) Error, < operator is not valid for tuples
d) Error, < operator is valid for tuples but not if there are sub-tuples

Q 3. What will be the output?


l = [None] * 10
print(len(l))

a) 10
b) 0
c) None
d) syntax error

Q 4. What will be the value of


True**False+True
a) True
b) 1
c) 2
d) 0

Q 5 . What will be the output of the given-


Games = {}
Games[1.0] = 8
Games[1] = 10
Games[(1,)] = 12
sum = 0
for k in Games:
sum += Games[k]
print (len(Games) + sum)

a) 33
b) 22
c) 25
d) none of above

Q 6. What is the output of the following?


i=0
while i < 3:
print(I, end=” ”)
i += 1
else:
print(0)
a) 0 1 2 3 0
b) 0 1 2 0
c) 0 1 2
d) error

Q 7. What will be the output of following?


x= "abcdef"
i = "i"
while i in x:
print(i, end=" ")
a) no output
b) i i i i i i …
c) a b c d e f
d) abcdef

Q 8. What is the output of the following?


print("xyyzxyzxzxyy".count('yy', 2))
a) 2
b) 0
c) 1
d) none of the mentioned

Q 9. Consider the following function call statement:


Change(10, p)
here p and 10 are?
a) variable and expression argument
b) literal and variable argument
c) variable argument and literal
d) None of the above

Q 10. Functions that do not return any value are known as:
a) fruitful functions
b) void functions
c) library functions
d) user-defined functions

Q 11. What is the error in the following code?

def fun(a=1, b):


a) Non default arguments cannot follow default arguments
b) Non default arguments can follow default arguments
c) No error
d) Invalid syntax

Q 12. Which is the correct command to load just the temp method from a module
called usable?
a) import usable, temp
b) import temp from usable
c) from usable import temp
d) import temp

Q 13. Write the output of the following code-


a = True
b = False
c = True
if not a or b:
print ("a")
elif not a or not b and c:
print ("b")
elif not a or b or not b and a:
print ("c")
else:
print ("d")
a) a
b) b
c) c
d) d

Q 14. To read 20 characters from file object FILE at once we may use-
a) FILE.read(20)
b) FILE.readlines(20)
c) FILE.read(char=20)
d) FILE.readline(char=20)
Q 15. read() will return ...................
a) list
b) string
c) tuple
d) dictionary

Q 16. If we do not specify file mode while opening a file, the file will open in
.............mode
a) Read
b) write
c) append
d) will give an error

Q 17. Which of the following mode is used when dealing with non-text files like
image or exe files?

a) Text mode
b) Binary mode
c) csv mode
d) none of the above

Q 18. Which of the following is not true about binary files?


a) Binary files are store in terms of bytes
b) When you open binary file in text editor will show garbage values
c) Binary files represent ASCII value of characters.
d) All of the above

Q 19. The pickle module in Python is used for:


a) Serializing any Python object structure
b) De-serializing Python object structure
c) Both a and b
d) None of these

Q 20. seek() function is used for .


a) positions the file object at the specified location.
b) It returns the current position of the file object
c) It writes the data in binary file
d) None of these

Q 21. This method returns an integer that specifies the current position of the file
object.
a) seek()
b) load()
c) position()
d) tell()

Q 22. Which of the following command is used to open a file “c:\temp.txt” for writing
in binary format only?
a) outfile = open(“c:\temp.txt”, “w”)
b) outfile = open(“c:\\temp.txt”, “wb”)
c) outfile = open(“c:\temp.txt”, “w+”)
d) outfile = open(“c:\\temp.txt”, “wb+”)

Q 23. Which of the following options can be used to read the first line of a text file
data.txt?
a) f = open(‘data.txt’)
f.read()
b) f = open(‘data.txt’,’r’)
f.read(n)
c) myfile = open(‘data.txt’)
f.readline()
d) f = open(‘data.txt’)
f.readlines()

Q 24. Which statement will move file pointer 10 bytes backward from current
position?
a) f.seek(-10, 0)
b) f.seek(10, 0)
c) f.seek(-10, 1)
d) None of the above

Q 25. Rishi opened a file in python using open() function but forgot to specify the
mode. In which mode the file will open?
a) write
b) append
c) read
d) read and write both

You might also like