Question: In Python: a. Write a program that asks the user for the name of a txt file (we will use suess.txt as the test file)
In Python:
a.
Write a program that asks the user for the name of a txt file (we will use suess.txt as the test file) and to pick either "odd" or "even". Then the program reads this file and prints only odd or even numbered lines of the input file's contents, depending on which the user picks (presume the first line is line 1). For example, if the file contains the lines:
Do you like green eggs and ham? I like them, Sam I am! Do you like green eggs and ham, Sam? Do you like them, Sam I am?
And the user chooses odd, output:
Do you like green eggs and ham? Do you like green eggs and ham, Sam?
b.
Write a program that takes two filenames from a user one for input (we will use suess.txt as the test file) and one for output. Then the program reads the specified input file and creates the new output file that contains every fifth character from the input file only if that character is a letter. In addition, the character should be uppercase if it is a vowel, and lowercase if it is a consonant. Finally, the program should output statistics for the altered text, including:
The number of characters
The number of consonants
The number of vowels
For example, if the input file contains:
Do you like green eggs and ham? I like them, Sam I am! Do you like green eggs and ham, Sam? Do you like them, Sam I am?
Then the output file should be:
OkEgnmltIOkEgnmmltI The number of characters: 19 The number of consonants: 13 The number of vowels:6
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
