Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CSC 311 Fall 2018 Homework Assignment 2 Due: TeD Python Programs and Files -80 Points For this assignment, you may work in groups of two

image text in transcribed

image text in transcribed

CSC 311 Fall 2018 Homework Assignment 2 Due: TeD Python Programs and Files -80 Points For this assignment, you may work in groups of two students, however, both students MUST write at least one program from Part 1 and at least one program from Part 2 by yourself with some help from your partner (not code) and the other one may be written by either student (or both). Hint: You will be doing at least two of these programs on the first test! For this homework assignment, all parts are SEPARATE programs (so middle, tail_head, split, and each sub-part of Part 2 are individual programs), so joining them into together will cost you points Part 1 40 points middle 10 points, tail_head 10 points, split 20 points Write a complete Python program with prompts for the user to get the main text file (checks that it exists, and if not, output an error message and stop), for any possible flags (flags allows the user to change the default conditions or to use the defaults, and for any other input that this program may need from the user: split has an option of naming the smaller files. Your program will open the input file once only and using seek(0) to avoid re-opening the fle will cost you all points for that part! list the middle lines of the file by skipping the first 5 lines (default) and skipping the last 5 lines (default) in order of the given text file middle change the number of lines to skip at the top and bottom flag: Comment If the file has less than 2 times the number of lines to skip, output the entire file list the last 5 lines (default) in order first and the first 5 lines (default) second in order of the given text file tail_head output # lines instead of 5 (default) lines flag: Comment: If the file has less than 2 times the requested number of lines, output the entire file in the requested order split a text file into smaller files (may be useful with the FTP Project) split flags put # lines of text into each output file (default 1000 lines) input file name file to be split (note extension and use it on split files) file of newfiles (example: name-aa.ext, name-ab.ext, etc.) name may be blank so the files are: xaa.ext, xab.ext, etc. (letters only, no numbers)- note: y program generates the file names - no external file of names allowed! Comment Output the name of the file as it is being created and filled Homework 2 Page 2 Part 2 Part A Write a program to count and output the total count of characters requested to the screen the numbers of times your initials (first and last names in either case) occur in the text file. For example: Your name is "Mary Brown", the program outputs the total number of times M's, m's, B's, b's occur (one number only) to the screen and the first line number that.the first and last Initials occur or zero if they don't exist in the same line. 40 points 15 points Part B 10 points Write a program to read in each line of your text file, sort all possible words contained in each line (if the line is blank or has only one word, just output it to the new file), then output each new line with one space between the sorted words to a new file called "sorted_lines.txt". Words starting with an Uppercase letter will be sorted first, then words starting with lowercase letter words be later in the list of words. For example, if the line is: A quick brown fox jumped over the lazy dog The output line is: A brown dog. fox jumped lazy over quick the 15 points Part C Write a program to find and output to a new text file all possible sorted words found in your text file containing your initials in either order and/or either case and/or together or separated by one to many other letters and how many times each word occurs. Example: Initials 'hw' yields "how" or "which" or "When 15 points Part EC Write a program to find and count, and then output all of the different sorted characters and their count to a new text file that follow either the initials of your first name or your last name in your text file in either case

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database Technology

Authors: Suad Alagic

1st Edition

354096276X, 978-3540962762

More Books

Students also viewed these Databases questions