Computer Science With Python Chapter 7 Data File Handling
  • Sponsor Area

    NCERT Solution For Class 12 Computer And Communication Technology Computer Science With Python

    Data File Handling Here is the CBSE Computer And Communication Technology Chapter 7 for Class 12 students. Summary and detailed explanation of the lesson, including the definitions of difficult words. All of the exercises and questions and answers from the lesson's back end have been completed. NCERT Solutions for Class 12 Computer And Communication Technology Data File Handling Chapter 7 NCERT Solutions for Class 12 Computer And Communication Technology Data File Handling Chapter 7 The following is a summary in Hindi and English for the academic year 2021-2022. You can save these solutions to your computer or use the Class 12 Computer And Communication Technology.

    Question 1
    CBSEENCO12011548

    Write a method in Python to read lines from a text file DIARY.TXT, and display those lines, which are starting with an alphabet ‘P’.

    Solution
    def display():
    	file=open('DIARY.TXT','r')
    	line=file.readline()
    	while line:
    		if line[0]=='P' :
    			print line
    			line=file.readline()
    	file.close() #IGNORE
    Question 4
    CBSEENCO12011694

    Differentiate between the following:

    1. f = open(‘diary.txt’, ‘r’)
    2. f = open(‘diary.txt’, ‘w’)

    Solution
    1. diary.txt is opened for reading data.
    2. diary.txt is opened for writing data.
    Question 5
    CBSEENCO12011695

    Write a method in python to read the content from a text file diary.txt line by line and display the same on screen.

    Solution
    def read_file():
    	inFile = open('diary.txt', 'r')
    	for line in inFile:
    		print line

    Mock Test Series

    Sponsor Area

    Sponsor Area

    NCERT Book Store

    NCERT Sample Papers

    Entrance Exams Preparation

    29