Samad3 3
Samad3 3
Experiment 3.3
1) Aim:
Program to demonstrate read and write data to the file in various modes.
1) Write a Python program to generate 26 text files named A.txt, B.txt, and so
on up to Z.txt
2) Write a Python program to create a file where all letters of English alphabet
are listed by specified number of letters on each line
Code
Output
Code import
random def
random_line(fname):
lines = open(fname).read().splitlines()
return random.choice(lines)
print(random_line('testfile1.txt'))
Output
Code
Output
Output
Previous:
Updated: