This quiz works best with JavaScript enabled. Home > Cbse > Class 11 > Science > Computer Science > Class 11 Computer Science Chapter 6 File Handling – Quiz 9 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 6 File Handling Quiz 9 (60 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. When using the read method to read characters from a file, what does the parameter "X" specify? A) The file format. B) The access mode. C) The number of characters to read. D) The file name. Show Answer Correct Answer: C) The number of characters to read. 2. What is a CSV file used for? A) Storing pictures. B) Compressed files. C) Running programs. D) Saving simple tables of data. Show Answer Correct Answer: D) Saving simple tables of data. 3. What type of data does the 'write' function handle in binary file operations? A) Data in its original format. B) Integer data only. C) Text data only. D) Character data only. Show Answer Correct Answer: A) Data in its original format. 4. Which function open file in python? A) Open(). B) New(). C) All the above. D) None of the above. Show Answer Correct Answer: A) Open(). 5. Which function is used to explicitly close an opened file in C? A) Fread(). B) Fopen(). C) Fclose(). D) Fwrite(). Show Answer Correct Answer: C) Fclose(). 6. Defined a statement with default value calculate(principle, rate, interest) which is the correct statement A) Calculate(principal=600, rate=250, interest=.5). B) Calculate(). C) Calculate(principle, rate, interest=.25). D) Calculate(principle=400, rate=250). Show Answer Correct Answer: A) Calculate(principal=600, rate=250, interest=.5). 7. How do you handle exceptions when working with file operations? A) Ignore exceptions and continue processing files. B) Log errors to a file without handling them. C) Use try-except blocks to catch and handle exceptions during file operations. D) Always delete the file if an error occurs. Show Answer Correct Answer: C) Use try-except blocks to catch and handle exceptions during file operations. 8. Which line would write a score to a file A) File.writeLine(scores[x]). B) File.writeLine(username[x]). C) File.readLine(scores[x]). D) File.readLine(username[x]). Show Answer Correct Answer: A) File.writeLine(scores[x]). 9. What command can you use to separate parts of a line? A) Divide(). B) Separate(). C) Cut(). D) Split(). Show Answer Correct Answer: D) Split(). 10. What does 'rb' mean in open()? A) Read text. B) Read binary. C) Reboot file. D) Read in reverse. Show Answer Correct Answer: B) Read binary. 11. What happens when a file is opened in read mode which is in fact not existing? A) File is automatically created. B) Error raised. C) Let's the user create one. D) A test file is automatically created. Show Answer Correct Answer: B) Error raised. 12. In Python, which file the user cannot able to read ..... A) Text File. B) Data Files. C) Binary File. D) CSV File. Show Answer Correct Answer: C) Binary File. 13. What is CPU scheduling and why is it necessary? A) CPU scheduling is used to enhance network security protocols. B) CPU scheduling is a technique for managing disk space allocation. C) CPU scheduling is essential for managing process execution and optimizing system performance. D) CPU scheduling is a method for increasing memory usage efficiency. Show Answer Correct Answer: C) CPU scheduling is essential for managing process execution and optimizing system performance. 14. Which function read single line at a time? A) Read(n). B) Readlines(). C) Read(). D) Readline(). Show Answer Correct Answer: D) Readline(). 15. How can data be retrieved into a program after it has been previously saved and closed? A) By creating a new data file. B) By loading the data back into the program. C) By restarting the computer. D) By emailing the data to oneself. Show Answer Correct Answer: B) By loading the data back into the program. 16. What is exception handling? A) A way to anticipate and handle errors. B) A way to restrict the values a user can enter. C) A way to prevent the program from crashing if an error occurs. D) A way to check for invalid input or values. Show Answer Correct Answer: C) A way to prevent the program from crashing if an error occurs. 17. Which of the following class is used for input and output operation when working with bytes? A) InputStream. B) Writer. C) Reader. D) All of given. Show Answer Correct Answer: A) InputStream. 18. What is always one of the aims for a developer creating a program? A) Memorize large texts. B) Learn a new language. C) Create visual art. D) Decompose tasks into sub-tasks. Show Answer Correct Answer: D) Decompose tasks into sub-tasks. 19. Which of the following function is used to write data in the text file. A) Write(). B) Load(). C) Output(). D) Dump(). Show Answer Correct Answer: A) Write(). 20. How is the 'fstream' class different from 'ifstream' and 'ofstream'? A) It can read and write files. B) It can only write files. C) It is used for binary files only. D) It can only read files. Show Answer Correct Answer: A) It can read and write files. 21. What is the code to open a file named as Sample and append output to the end of this file? A) Open("Sample.dat", "ios.app"). B) Open(ios::app, "Sample.dat"). C) Open("ios.app", "Sample.dat"). D) Open("Sample.dat", ios::app). Show Answer Correct Answer: D) Open("Sample.dat", ios::app). 22. How to open a file safely for reading? A) Open('file.txt', 'w'). B) File = open('file.txt'). C) File = file('file.txt'). D) With open('file.txt') as file. Show Answer Correct Answer: D) With open('file.txt') as file. 23. Files have two modes of operation-read from and write to. A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: A) True. 24. How can you read binary data from a file in Python? A) Read binary data using open('filename', 'wt') method. B) Use open('filename', 'rb') to read binary data from a file. C) Use open('filename', 'text') to read binary data from a file. D) Use open('filename', 'r') to read binary data from a file. Show Answer Correct Answer: B) Use open('filename', 'rb') to read binary data from a file. 25. How do you close a file after reading or writing in Python? A) Close(file). B) File.stop(). C) File.close(). D) File.close(file). Show Answer Correct Answer: C) File.close(). 26. What is the method used to read the entire content of a file in Python? A) File.load(). B) File.read all(). C) File.open(). D) File.read(). Show Answer Correct Answer: D) File.read(). 27. What is the function used to get the current working directory in Python? A) Os.currentdir(). B) Os.getcwd(). C) Os.chdir(). D) Os.getdir(). Show Answer Correct Answer: B) Os.getcwd(). 28. What is the first step to read a file in Python? A) Delete the file. B) Print the file. C) Open the file. D) Rename the file. Show Answer Correct Answer: C) Open the file. 29. In Text file, each line of text is terminated with special character known as ..... A) EOL. B) Endl. C) Carriage Return. D) CSV. Show Answer Correct Answer: A) EOL. 30. The difference between 'r+' and 'w+' modes is that 'r+' empties the file first, while 'w+' does not. A) TRUE. B) FALSE. C) All the above. D) None of the above. Show Answer Correct Answer: B) FALSE. 31. What is the full form of CSV? A) Common separated value. B) Comma separated value. C) Comma secured value. D) None. Show Answer Correct Answer: B) Comma separated value. 32. What function is used to open a file in Python? A) LoadFile(). B) FileOpen(). C) ReadFile(). D) Open(). Show Answer Correct Answer: D) Open(). 33. How can you read a text file in Python? A) Open('file.txt', 'w').read(). B) Read('file.txt'). C) Open('file.txt', 'r').read(). D) Open('file.txt').read(). Show Answer Correct Answer: C) Open('file.txt', 'r').read(). 34. To read the next line of the file from a file object called F ..... H, we use A) F H.readlines(). B) F H.read(all). C) F H.readline(). D) F H.read(). Show Answer Correct Answer: C) F H.readline(). 35. To unpickle the data coming from the file ..... function of the pickle module is used. A) Pickle.load(). B) Pickle:load(). C) Pickle.load. D) Pickle, load(). Show Answer Correct Answer: A) Pickle.load(). 36. The suspicious code is put inside the A) Try Block. B) Finally Block. C) Else Block. D) Except Block. Show Answer Correct Answer: A) Try Block. 37. How do you get information from a form that is submitted using the "get" method? A) $ GET[];. B) Request.Form;. C) Request.QueryString;. D) None. Show Answer Correct Answer: A) $ GET[];. 38. File handle is another term for file name A) TRUE. B) FALSE. C) All the above. D) None of the above. Show Answer Correct Answer: B) FALSE. 39. Explain the process of reading a CSV file using the Reader function. A) Download csv file, read file line by line, convert each line to list. B) Open csv file, create csv.writer object, write data to file. C) Import csv module, open CSV file, create csv.reader object, iterate over reader object. D) Import pandas module, read csv file using pandas function. Show Answer Correct Answer: C) Import csv module, open CSV file, create csv.reader object, iterate over reader object. 40. Since Random Access Memory (RAM) is volatile which loses its data when computer is turned off, we use files for future use of the data. A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: A) True. 41. When you open a file for appending and if the file exist, the existing file is? A) Will be erased. B) Will be added with the new content. C) Will be overwritten. D) Will be added as a new file. Show Answer Correct Answer: B) Will be added with the new content. 42. Which of the following value is returned by read() method when end of file (EOF) is encountered? A) 0. B) Null. C) -1. D) 1. Show Answer Correct Answer: C) -1. 43. What does a single period (dot) represent in a path? A) This directory. B) The parent folder. C) All the above. D) None of the above. Show Answer Correct Answer: A) This directory. 44. Discuss the importance of closing a file after performing operations on it. A) Closing a file after performing operations on it helps release system resources and ensures data integrity and security. B) Leaving a file open improves system performance. C) Not closing a file enhances file security. D) Closing a file can lead to data loss. Show Answer Correct Answer: A) Closing a file after performing operations on it helps release system resources and ensures data integrity and security. 45. When does the finally block excecute? A) Only run if no errors happened. B) Only runs if we catch the error that occurred. C) There is no finally block. D) Always runs regardless of if error occurred. Show Answer Correct Answer: D) Always runs regardless of if error occurred. 46. What is the difference between read(10) and read()? A) Read(10) reads 10 characters and read() reads the entire content of the file and returns it in the form of a List . B) Read(10) reads 10 characters and read() reads the entire content of the file and returns it in the form of a string . C) Read(10) reads 10 characters and read() reads the entire content of the file and returns it in the form of List of String . D) All of the above. Show Answer Correct Answer: B) Read(10) reads 10 characters and read() reads the entire content of the file and returns it in the form of a string . 47. The files length can be found using the ..... function. A) Fsize(). B) Count(). C) Fcount(). D) Filesize(). Show Answer Correct Answer: D) Filesize(). 48. Which mode is used to open CSV file for writing? A) "wb". B) "wt". C) "w+". D) "w". Show Answer Correct Answer: D) "w". 49. What happens when a file is opened in write mode which is in fact not existing? A) File is automatically created. B) Error raised. C) Let's the user create one. D) A test file is automatically created. Show Answer Correct Answer: A) File is automatically created. 50. What is the function of fwrite()? A) Writes data to a file. B) Renames a file. C) Checks for end of file. D) Reads formatted input from a file. Show Answer Correct Answer: A) Writes data to a file. 51. Which of the following functions do you use to write data in the binary format using PICKLE module? A) Output. B) Send. C) Dump. D) Write. Show Answer Correct Answer: C) Dump. 52. Write the method to read from a csv file A) Readlines(). B) Read(). C) Reader(). D) Readline(). Show Answer Correct Answer: C) Reader(). 53. What is the purpose of CSV File Handling in Python? A) The purpose of CSV File Handling in Python is to read, write, and manipulate data stored in CSV files. B) CSV File Handling in Python is designed for creating 3D graphics. C) The purpose of CSV File Handling in Python is to play audio files. D) CSV File Handling in Python is used for image processing. Show Answer Correct Answer: A) The purpose of CSV File Handling in Python is to read, write, and manipulate data stored in CSV files. 54. Which of the following functions changes the position of file pointer and returns its new position? A) Offset(). B) Flush(). C) Tell(). D) Seek(). Show Answer Correct Answer: D) Seek(). 55. ..... is the other name for the file object? A) File. B) File pointer. C) File handle. D) File name. Show Answer Correct Answer: C) File handle. 56. Which logical operator is used to checks for each and every condition is true? A) And. B) Or. C) Not. D) None. Show Answer Correct Answer: A) And. 57. Files that can be read bye text editors are called A) Text. B) Editor. C) Binary. D) Source. Show Answer Correct Answer: A) Text. 58. Why is it important to close a file after operations in Python? A) To release system resources and ensure data is written properly. B) To speed up file operations. C) To save memory space. D) To increase system performance. Show Answer Correct Answer: A) To release system resources and ensure data is written properly. 59. How can you read a specific number of characters from a file? A) Read the entire file and then slice the string. B) Use 'file.get(n)' to retrieve characters. C) Use 'file.readline(n)' to read a specific number of characters. D) Use 'file.read(n)' after opening the file. Show Answer Correct Answer: D) Use 'file.read(n)' after opening the file. 60. What function is used to open a file in Python for writing? A) Open('filename.txt', 'r'). B) Write('filename.txt'). C) Open('filename.txt', 'w'). D) Create('filename.txt'). Show Answer Correct Answer: C) Open('filename.txt', 'w'). ← PreviousNext →Related QuizzesScience QuizzesClass 11 QuizzesClass 11 Computer Science Chapter 6 File Handling Quiz 1Class 11 Computer Science Chapter 6 File Handling Quiz 2Class 11 Computer Science Chapter 6 File Handling Quiz 3Class 11 Computer Science Chapter 6 File Handling Quiz 4Class 11 Computer Science Chapter 6 File Handling Quiz 5Class 11 Computer Science Chapter 6 File Handling Quiz 6Class 11 Computer Science Chapter 6 File Handling Quiz 7Class 11 Computer Science Chapter 6 File Handling Quiz 8 🏠 Back to Homepage 📘 Download PDF Books 📕 Premium PDF Books