Python 3.3 Ash
Python 3.3 Ash
Python 3.3 Ash
Experiment - 3.3
1. Write a Python program to generate 26 text files named A.txt, B.txt, and so on up to
Z.txt
Code:-
import string
Output
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
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-
import string
num_letters_per_line = 5
alphabet = string.ascii_uppercase
Output:
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
Code:
import random
filename = "alphabet.txt"
with open(filename, "r") as file:
lines = file.readlines()
random_line = random.choice(lines)
print(random_line.strip())
Output:
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
Code:
filename = "alphabet.txt"
word_counts = {}
Output:
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
Code:
source_file = "alphabet.txt"
destination_file = "destination.txt"
Output: