Data file handling in python class 12 you get important Questions for File Handling – Computer Science with Python. For answers check out these posts: Show
Fill in the blanks
Find answer below for data file handling in python class 12. Answers:
Data file handling in python class 12 – MCQs1 Every file has its own identity associated with it. Which is known as – a. icon b. extension c. format d. file type 2 Which of the following is not a known file type? a. .pdf b. jpg c. mp3 d. txp 3. In f=open(“data.txt”, “r”), r refers to __________. a. File handle b. File object c. File Mode d Buffer 4. EOL stands for a. End Of Line b. End Of List c. End of Lines d. End Of Location 5. Which of the following file types allows to store large data files in the computer memory? a. Text Files b. Binary Files c. CSV Files d. None of these
6. Which of the following file types can be opened with notepad as well as ms excel? a. Text Files b. Binary Files c. CSV Files d. None of these 7. Which of the following is nor a proper file access mode? a. close b. read c. write d. append 8. To read 4th line from text file, which of the following statement is true? a. dt = f.readlines();print(dt[3]) b. dt=f.read(4) ;print(dt[3]) c. dt=f.readline(4);print(dt[3]) d. All of these 9 Which of the following function flushes the files implicitly? a. flush() b. close() c. open() d. fflush() 10. Which of the following functions flushes the data before closing the file? a. flush() b. close() c. open() d. fflush() data file handling in python class 12 – Short answer questions/ Conceptual QuestionsPlease refer notes section for the answers on Data file handling in python class 12.
data file handling in python class 12 – Application-Based questionsThe following section contains few case study based questions for Data file handling in python class 12.
Answer:
2. Consider following lines for the file friends.txt and predict the output: Friends are crazy, Friends are naughty ! Friends are honest, Friends are best ! Friends are like keygen, friends are like license key ! We are nothing without friends, Life is not possible without friends !
Output: Friends are honest Explanation: In line no. 2, f.readline() function reads first line and stores the output string in l but not printed in the code, then it moves the pointer to next line in the file. In next statement we have f.readline(18) which reads next 18 characters and place the cursor at the next position i.e. comma (,) , in next statement f.read(10) reads next 10 characters and stores in ch3 variable and then cursor moves to the next position and at last f.readline() function print() the entire line. 3. Write a function count_lines() to count and display the total number of lines from the file. Consider above file – friends.txt.
4. Write a function display_oddLines() to display odd number lines from the text file. Consider above file – friends.txt.
5. Write a function cust_data() to ask user to enter their names and age to store data in customer.txt file.
Thank you very much for visiting our website and reading the article data file handling in python class 12. Click here to read data file handling in python class 12 notes for text files. Kindly share the contents to help the community and your friends. Share your views in the comment section about this article. Feel free to ask your doubts in the comments section as well. If you are looking for Sumita Arora textbook solutions on Data file handling in python class 12 click here. If you need more questions and assignments let us know in the comments on the topic Data file handling in python class 12. Download the contents in pdf file. Post navigationWhat is a file handling in Python?File Handling
The key function for working with files in Python is the open() function. The open() function takes two parameters; filename, and mode. There are four different methods (modes) for opening a file: "r" - Read - Default value. Opens a file for reading, error if the file does not exist.
What do you mean by file handling?File handling refers to the method of storing data in the C program in the form of an output or input that might have been generated while running a C program in a data file, i.e., a binary file or a text file for future analysis and reference in that very program.
Why is file handling important in Python?Importance of File Handling in Python
Now if data is small then this processing can be done every time you run the script but in case of humongous data repetitive processing cannot be performed, hence the processed data needs to be stored. This is where data storage or writing to a file comes in.
What are the different types of files handling in Python?There are two types of files that can be handled in python, normal text files and binary files (written in binary language, 0s, and 1s). Text files: In this type of file, Each line of text is terminated with a special character called EOL (End of Line), which is the new line character ('\n') in python by default.
|