B04B-2017D – Computer Sir Ki Class

Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  

Login
[lwa]



Exam Questions-CBSE12D-2017-B04B #PYTHON#6435    siteicon   siteicon  

Problem Statement - B04B-2017D

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

TC++ #6435

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


Share

CSKC| Created: 12-Jan-2019 | Updated: 12-Jan-2019|CBSE12D-2017









Back