vtcbca / internal-exam-23bca286

23bca-python-sqlite-internal-exam-303-PYTHON-EXAM created by GitHub Classroom
0 stars 0 forks source link

python text file program #4

Open 23bca286 opened 1 month ago

23bca286 commented 1 month ago

**Create BCA.txt. Write 5 lines directly and 5 lines must be taken from user. Print the smallest and largest word in this file.

f=open("D:\23BCA286\DATA\bca.text","w")

f.write("bca is my favourite cource\ bca is a three years undergraduated cource\ this cource in this 6 semester\ this cource is designed to student carier in IT industry\ BCA stads for bachelor of computer application")

l1=[]

for i in range(5): s=input("enter any sentence: ") l1.append(s)

enter any sentence: bca is my favourite cource enter any sentence: bca is a three years undergraduated cource enter any sentence: this cource in this 6 semester enter any sentence: this cource is designed to student carier in IT industry enter any sentence: BCA stands for bachelor of computer application

f.writelines(l1)

f.close()

f=open("D:\23BCA286\DATA\bca.text","r")

l=f.readlines()

print(l)

['bca is my favourite cource bca is a three years undergraduated cource this cource in this 6 semester this cource is designed to student carier in IT industry BCA stads for bachelor of computer applicationbca is my favourite courcebca is a three years undergraduated courcethis cource in this 6 semesterthis cource is designed to student carier in IT industryBCA stands for bachelor of computer application']

23bca283 commented 1 month ago

why you use readlines().