12 Cs Final Mock Objective Type July 2021

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

MOCK OBJECTIVE TYPE

ASSESSMENT
SUBJECT- COMPUTER SCIENCE
CLASS- XII
Time: 45 MINUTES M.M.: 45
Instructions:
1. This question paper contains 45 Multiple-Choice Questions of 1 mark each.
2. All programming questions are to be answered using Python Language only

SECTION -A (1 MARK EACH)

1. All keywords in Python are in _________


a) lower case
b) UPPER CASE
c) Capitalized
d) None of the mentioned

2. Which of the following is an invalid variable?


a) my_string_1
b) 1st_string
c) foo
d) _

3. Is Python case sensitive when dealing with identifiers?


a) Yes
b) No
c) machine dependent
d) none of the mentioned
4. What will be the output of the following Python statement?
>>>"a"+"bc"
a) a
b) bc
c) bca
d) abc

5. What will be the output of the following Python code?


>>> str1 = 'hello'
>>> str2 = ','
>>> str3 = 'world'
>>> str1[-1:]

a) olleh
b) hello
c) h
d) o

6. What arithmetic operators cannot be used with strings?


a) +
b) *
c) –
d) All of the mentioned

7. What will be the output of the following Python code?


>>>str1="helloworld"
>>>str1[::-1]

a) dlrowolleh
b) hello
c) world
d) helloworld
8. What will be the output of the following Python code.
>>>max("what are you")
a) error
b) u
c) t
d) y

9. Given a string example=”hello”. What is the output of example.count(‘l’)?


a) 2
b) 1
c) None
d) 0

10. What will be the output of the following Python code?


>>>example = "helle"
>>>example.find("e")
a) Error
b) -1
c) 1
d) 0

11. Say s=”hello” what will be the return value of type(s)?


a) int
b) bool
c) str
d) String

12. What is “Hello”.replace(“l”, “e”)?


a) Heeeo
b) Heelo
c) Heleo
d) None
13. What will be the output of the following Python code?
print('ab12'.isalnum())

a) True
b) False
c) None
d) Error

14. To read two characters from a file object infile, we use ____________
a) infile.read(2)
b) infile.read()
c) infile.readline()
d) infile.readlines()

15. To read the entire contents of the file as a string from a file object infile, we use
a) infile.read(2)
b) infile.read()
c) infile.readline()
d) infile.readlines()

16. To read the next line of the file from a file object infile, we use ____________

a) infile.read(2)
b) infile.read()
c) infile.readline()
d) infile.readlines()

17. Which one of the following is not attributes of file?


a) closed
b) mode
c) rename
18. What is the use of tell() method in python

a) tells you the current position within the file


b) tells you the end position within the file
c) tells you the file is opened or not
d) none of the mentioned

19. What is the current syntax of rename() a file?


a) rename(current_file_name, new_file_name)
b) rename(new_file_name, current_file_name,)
c) rename(()(current_file_name, new_file_name))
d) none of the mentioned

20. Correct syntax of file.readlines() is?


a) fileObject.readlines(sizehint );
b) fileObject.readlines();
c) fileObject.readlines(sequence)
d) none of the mentioned

21. In file handling, what does this terms means “r, a”?
a) read, append
b) append, read
c) write, append
d) none of the mentioned

22. Which function is used to write all the characters?


a) write()
b) writecharacters()
c) writeall()
d) writechar()
23. Which function is used to write a list of string in a file?
a) writeline()
b) writelines()
c) writestatement()
d) writefullline()

24. Which function is used to close a file in python?


a) close()
b) stop()
c) end()
d) closefile()

25. Which of the following are the modes of both writing and reading in binary format in file?
a) wb+
b) w
c) wb
d) w+

26. How do you get the current position within the file?
a) fp.seek()
b) fp.tell()
c) fp.loc
d) fp.pos

27. How do you close a file object (fp)?


a) close(fp)
b) fclose(fp)
c) fp.close()
d) fp.__close__()
28. Which of the following is not a known file type?
a .pdf
b. jpg
c. mp3
d. txp

29. Ms. Suman is working on a binary file and wants to write data from a list to a binary file.
Consider list object as l1, binary file suman_list.dat, and file object as f. Which of the following can
be the correct statement for her?
a) f = open(‘sum_list’,’wb’); pickle.dump(l1,f)
b) f = open(‘sum_list’,’rb’); l1=pickle.dump(f)
c) f = open(‘sum_list’,’wb’); pickle.load(l1,f)
d) f = open(‘sum_list’,’rb’); l1=pickle.load(f)

30. Which option will be correct for reading file for suman from above question?
a) f = open(‘sum_list’,’wb’); pickle.dump(l1,f)
b) f = open(‘sum_list’,’rb’); l1=pickle.dump(f)
c) f = open(‘sum_list’,’wb’); pickle.load(l1,f)
d) f = open(‘sum_list’,’rb’); l1=pickle.load(f)

31. In which of the file mode existing data will be intact in binary file?
a) ab
b) a
c) w
d) wb

32. Which one of the following is correct statement?


a) import – pickle
b) pickle import
c) import pickle
d) All of the above
33. You cannot change the by default comma as a value separater.
a) TRUE
b) False

34. The default line terminator is \n in csv file.


a) True
b) False

35. Which of the following module is required to import to work with CSV file
a) File
b) CSV
c) Pandas
d) Numpy

36. Which of the following is not a function of csv module?


a) readline()
b) writerow()
c) reader()
d) writer()
37. Which of the following parameter needs to be added with open function to avoid blank
row followed file each row in CSV file?
a) qoutechar
b) quoting
c) newline
d) skiprow

38. Anshuman wants to separate the values by a $ sign. Suggest to him a pair of function and
parameter to use it.
a) open,quotechar
b) writer,quotechar
c) open,delimiter
d) writer, delimiter

39. Which of the following commands would you use to start Python from the command
prompt?
a) run python
b) python
c) execute python
d) go python

40. Select the statement(s) correctly explain the usage of seek() method?
a. tell the current position within the file.
b. indicate that the next read or write occurs from that position in a file.
c. determine if you can move the file position or not.
d. move the current file position to a different location at a defined offset

41. Which of the following functions do you use to write data in the binary format?
a) write
b) Load
c) dump
d) send

42. Select from the following valid arithmetic operator in Python:

a) //
b) ?
c) <
d) And

43. Select from the following the type of tokens for ' if ':

a) KEYWORD
b) OPERATOR
c) IDENTIFIER
d) NONE OF THE ABOVE

44. Iteration statements(loop) are used to execute a block of statements as long as the condition is
satisfied.
a) True
b) False

45. Predict output of following expression:


((5<10) and (10<5) or (3<18) and not 8<18)

a) False
b) True
c) 5
d) 10

You might also like