Table of Contents
Class 12 Computer Science MCQ
The Central Board of Secondary Education is going to conduct the Class 12th Computer Science Examination . On this page, we have provided Class 12th Computer Science MCQs so that students can practice these questions and pass the class 12th examination with flying colors. This year, the CBSE has changed the exam pattern, the questions will be of objective type questions, so here we have given important objective type questions for the practice of students appearing for the Computer Science Term 1 examination. In this article, we have covered topics like python, data file handling, etc. The students are advised to go through the entire article, we have covered the important questions which can be asked in the main examination. Ignoring any question can lead to a loss of marks.
Class 12th Computer Science MCQ Important Questions with Answers
Read all the Class 12th Computer Science MCQs is given below:
- Python identifiers are case-sensitive.
a)True
b) False
c) Depends on Program
d) Depends on the computer system
Answer: True
- Arrange the following file handling operations in proper order:
A) Close the file
B) Perform operations on file
C) Opening the file
a) C – B – A
b) A – B – C
c) A – C – B
d) C – B – A
Ans. d) C – B – A
- The pickle.load() function requires minimum _____ number of parameters
a) 0
b) 1
c) 2
d) 3
Ans. b) 1
- Which of the following function is used to write steam data from python console to binary file?
a) load()
b) dumps()
c) dump()
d) write()
Ans. c) dump
- User need to call load() each time dump() is called.
a) Yes, it must be
b) No, Not necessarily
c) Depends on the file operations
d) All of the above
Ans. a) Yes, It must be
- The dump method requires _________ minimum no of parameters
a) 1
b) 2
c) 0
d) None of these
Ans. b) 2
- Pickling refers to
a) converting the structure to a byte stream before working to the file
b) converting the structure to a file in unicode
c) converting the structure to a file in text file
d) converting the structure to a csv filve
Ans. a) converting the strucgture to a byte stream before working to the file
- Select the correct statements for sys.stderr:
i) It is used to provide error messages.
ii) It is similar as sys.stdout
iii) It does not print only exceptions but prints error messages with debugging comments
iv) Can be linked to the standard input of another program with a pipe symbol
a) ii, iii and iv
b) i, ii and iv
c) i and iv only
d) i, ii and iii
Ans. d) i, ii and iii
- Statement A: Data written to sys.stdout appears on screen.
Statement B: Data are written to sys.stdout can be linked to the standard input of another program with a pipe.
a) Statement A is True
b) Statement B is False
c) Statement B is True
d) Both statements A and B are True
Ans. d) Both statements A and B are True
- Mr. Alpesh wants to know the standard stream which reads the standard input in python. Select the correct stream from the following:
a) sys.stdin
b) sys.stdinput
c) sys.input
d) sys.standardin
Ans. a) sys.stdin
- Using with ensures that
i) all the resources allocated the file objects get deallocated automatically when the user stops using the file
ii) all files will be closed by itself
iii) do not require to close the file in case of exception as well
iv) it makes code more compact and readable
a) i, ii and iii
b) i, iii and iv
c) ii, ii and iv
d) ii, iii and iv
Ans.d)i, ii, iii and iv
- Python will raise error FileNotFounderror, if
a) the file is empty
b) the file is created but not in use
c) the file doesn’t exist
d) the file is opened in read mode
Ans. c) the file doesn’t exist
- To write data into CSV from python console, which of the following function is correct?
a) csv.write(file)
b) csv.writer(file)
c) csv.Write(file)
d) csv.writerow()
Ans. b) csv.writer(file)
- The write() function actually
a) writes into permanent location to the file
b) write into the buffer
c) write into the library
d) write into the program
Ans. b) write into buffer
- The ________ mode allows adding data into the existing file at the end of the file.
a) read
b) write
c) binary
d) append
Ans. d) append
- The with clause plays an important role in file handling when
a) File is opened for writing
b) File is opened for reading
c) File is closed
d) Exception occurs
Ans. d) Exception Occurs
17._________ clause close the opened file automatically once control comes outside the clause.
a) for clause
b) while clause
c) with clause
d) None of these
Ans. c)with clause
- The access_mode can be retrieved through
a) access_mode
b) process_mode
c) open_mode
d) select_mode
Ans. a) access_mode
- Atul wants to know that he has closed the file after performing the tasks. Which of the following function he can used to check whether the file is closed or not?
a) f.close()
b) f.closing()
c) f.closed()
d) There is no such function in python
Ans. c) f.closed()
- Statement A: It is always a good practice to close the file when read/write operations done in the file.Statement B: While closing a file system frees the memory allocated to it.
a) Statement A is Correct
b) Statement B is Correct
c) Statement A and Statement B are correct
d) Statement A and Statement B are incorrect
Ans. c) Statement A and Statement B are correct
- Puru wants to close a file after reading operation for the file object f. Suggest the correct function to him.
a) f.close()
b) f.close
c) f.quit()
d) f.exit()
Ans. a) f.close()
- In which of the following mode the file offset position is not at the begging of the file?
i) r, rb, r+ or +r, rb+ or +rb
ii) w, wb, wb+ or +wb
iii) a, a+ or +a
a) i, ii and iii
b) i, and ii only
c) iii only
d) ii and iii only
Ans. c) iii only
- Priya has placed the file pointer at 4th line in the text file. Now she wants to read all remaining lines of a text file. Which function is suitable for her, select the correct one:
a) f.read()
b) f.readlines()
c) f.read(n)
d) f.readlines()
Ans. d) f.readlines()
- Identify the function to read first 5 characters of the file from the beginning out of the following:
a) f.read(5)
b) f.read()=5
c) f.readline()
d) f.readlines(5)
Ans. a) f.read(5)
- Manoj wants to get the name of the current directory. Select appropriate statement for the same:
a) os.getcd()
b) os.getcurrentdirectory()
c) os.getcwd()
d) os.currentdirectory()
Ans. c) os.getcwd()
- The default directory for performing most of the functions is known as
a) active directory
b) current directory
c) working directory
d) open directory
Ans. b) current directory
- Which of the following are features of CSV files:
a) easy to read and manage
b) small in size
c) fast to process data
d) All of them
Ans. d) All of them
- Read the statements and choose the correct answer:
Statement A: It is very difficult to organize unstructured data
Statement B: CSV helps into organize a huge amount of data in a proper and systematic way
a) Only Statement A is correct
b) Only Statement B is correct
c) A and B both are correct
d) None of them is correct
Ans. c) A and B both are correct
- The CSV files can be accessed by
a) text editor and spreadsheet software
b) only through python programs
c) Only spreadsheet software
d) Only through database software
Ans. a) text editor and spreadsheet software
- A ___________ is a simple flat file in a human-readable format that is used to store data in a spreadsheet or database.
a) text file
b) database file
c) binary file
d) CSV file
Ans. CSV File
- Shiv wants to store the data of his customer using the python program. Suggest the best way to store the data?
a) Text Files
b) CSV files
c) Binary Files
d) Module File
Ans. c) Binary File
- Which of the following statement is not correct for text file?
A) Contains the information as same as its held in memory
B) No delimiter for a line
C) read and write faster than binary files
D) Common format for general work
a) A and B only
b) A, B and C
c) A, C and D
d) All of them
Ans. d) All of them
- In python which of the following is the default EOL character?
a) \eol
b) \enter
c) \n
d) \newline
Ans. c) \n
- Supriya doesn’t know about the text file extension. Help her to identify the same out of these:
a) .text
b) .txt
c) .txf
d) .tfx
Ans. b) .txt
- Which of the following format of files can be created programmatically through python program?
a) Data Files
b) Video Files
c) Media Files
d) Binary Files
Ans. d) Binary Files
- The ____________ are the files that store data pertaining to a specific application, for later use.
a) Data File
b) Program File
c) Source Code
d) Program Code
Ans. a) Data File
- Read the following statements and then select the answer:
Statement A: Default arguments can be used to add new parameters to the existing functions
Statement B: Default arguments can be used to combine similar functions into one
a) Statement A is correct
b) Statement B is correct
c) Both are correct
d) Both are incorrect
Ans. c) Both are correct
- Which of the following function header is correct :
a) def discount(rate=7,qty,dis=5)
b) def discount(rate=7,qty,dis)
c) def discount(rate,qty,dis=5)
d) def discount(qty,rate=7,dis)
Ans. c) def discount(rate,qty,dis=5)
- The default valued parameter specified in the function header becomes optional in the
function calling statement.
a) Yes
b) No
c) Not Sure
d) May be
Ans. a) Yes
- The positional parameters are also known as
a) required arguments
b) mandatory arguments
c) Both a and b
d) None of them
Ans. c) Both a and b
- Archi is confused between arguments and parameters. Select the fact about argument and parameter and solve her doubt
a) arguments are those values being passed and parameters are those values received
b) parameters are those values being passed and arguments are those values received
c) arguments appear in the function header and parameters appear in the function call
d) arguments can have same name and parameters can have value type
Ans. a) arguments are those values being passed and parameters are those values received
- In python function, the function calling another function is known as ________________ and the function being called is known _________
a) main, keyword
b) caller, called
c) called, caller
d) executer, execute
Ans. b) caller, called
- By default python names the segment with top-level statement as __________________
a) def main()
b) main()
c) __main__
d) _main
Ans. c) __main__
- Which of the following sentence is not correct for the python function?
a) Python function must have arguments
b) Python function can take an unlimited number of arguments
c) Python function can return multiple values
d) To return value you need to write the return statement
Ans. a) Python function must have arguments
- Rashmin is learning the python functions He read the topic types of python functions. He read that functions already available in the python library is called ___________. Fill appropriate word in this blank :
a) UDF (User Defined Function)
b) Built-in Functions
c) Modules
d) Reusable Function
Ans. b) Built-in functions
- Which of the following is not a feature supported by python functions
a) Modularity
b) Reusability
c) Simplicity
d) Data Hiding
Ans. d) Data Hiding
- Which of the function part contains the instructions for the tasks to be done in the function?
a) function header
d) function body
c) return statement
d) parameters
Ans. b) function body
- Richa is working with a program where she gave some values to the function. She doesn’t know the term to relate these values. Help her by selecting the correct option.
a) function value
b) arguments or parameters
c) return values
d) function call
Ans. b) arguments of parameters
- Read the statements:
Statement (A) : A function can perform certain functionality
Statement (B) : A function must return a result value
a) Statement A is correct
b) Statement B is correct
c) Statement A is correct but Statement B is not correct
d) Both are incorrect
Ans. c) Statement A is correct but Statement B is not correct
- The function header contains
a) function name and parameters only
b) def keyword along with function name and parameters
c) return statement only
d) parameter list only
Ans. b) def keyword along with function name and parameters
- Which of the following is not a part of the python function?
a) function header
b) return statement
c) parameter list
d) function keyword
Ans. d) function keyword
- Which of the following is a valid function name?
a) start_game()
b) start game()
c) start-game()
d) All of the above
Ans. a) start_game()
- Which of the following is not a correct statement for binary files?
a) Easy for carrying data into buffer
b) Much faster than other file systems
c) Characters translation is not required
d) Every line ends with new line character ‘\n’
Ans: d) Every line ends with new line character ‘\n’
- Which one of the following is correct statement?
a) import – pickle
b) pickle import
c) import pickle
d) All of the above
Ans: c) import pickle
- In which of the file mode existing data will be intact in binary file?
a) ab
b) a
c) w
d) wb
Ans: a) ab
- 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)
Ans: a) f = open(‘sum_list’,’wb’); pickle.dump(l1,f)
- Which option will be correct for reading file for suman from q-5?
–> Option ) f = open(‘sum_list’,’rb’); l1=pickle.load(f)
Which of the following file mode opens a file for reading and writing both as well as overwrite the existing file if the file exists otherwise creates a new file?
a) w
b) wb+
c) wb
d) rwb
Ans:b) wb+
- Which of the following is not a correct statement for binary files?
a) Easy for carrying data into buffer
b) Much faster than other file systems
c) Characters translation is not required
d) Every line ends with new line character ‘\n’
Ans: d) Every line ends with new line character ‘\n’
- Every file has its own identity associated with it. Which is known as –
- icon
- extension
- format
- file type
Ans: b. extension
- Which of the following is not a known file type?
a.pdf
b. jpg
c. mp3
d. Txp
Ans: d. txp
- In f=open(“data.txt”, “r”), r refers to __________.
a. Filehandle
b. File object
c. File Mode
d. Buffer
Ans: c. File Mode
- EOL stands for
- End Of Line
- End Of List
- End of Lines
- End Of Location
Ans: a. End Of Line
- Which of the following file types allows to store large data files in the computer memory?
- Text Files
- Binary Files
- CSV Files
- None of these
Ans: b. Binary Files
- Which of the following file types can be opened with notepad as well as ms excel?
- Text Files
- Binary Files
- CSV Files
- None of these
Ans: c. CSV Files
- Which of the following is nor a proper file access mode?
- close
- read
- write
- Append
Ans: a. close
- To read 4th line from text file, which of the following statement is true?
- dt = f.readlines();print(dt[3])
- dt=f.read(4) ;print(dt[3])
- dt=f.readline(4);print(dt[3])
- All of these
Ans: a. dt = f.readlines();print(dt[3])
- Which of the following function flushes the files implicitly?
- flush()
- close()
- open()
- fflush()
Ans: b. close()
- Which of the following functions flushes the data before closing the file?
- flush()
- close()
- open()
- fflush()
Ans: a. flush()
- Choose the correct function to rename city columns to location using rename() function:
- df.rename(columns={‘City’:’Location’})
- df.rename(columns={‘City’=’Location’})
- df.rename(‘City’=’Location’)
- df.rename(df.columns(‘City’,’Location’))
Ans: a. df.rename(columns={‘City’:’Location’})
- df.index properties ca be used to
a rename rows
b rename columns
c rename rows and columns both
d None of these
Ans: a rename rows
- In python function, the function calling another function is known as ________________ and the function being called is known _________
- a) main, keyword
- b) caller, called
- c) called, caller
- d) executer, execute
Ans. b) caller, called