Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

this is rquirement for all questions Make sure to validate user input for data type, value range and other problem requirements Print output that

"" this is rquirement for all questions Make sure to validate user input for data type, value range and other problem requirements Print output that clearly explains what is being printed (where necessary) o In other words, dont just print a 5 unless its clear what that 5 represents. Import statements should be immediately after the program docstring Make sure to include # line comments (just a few in each program, dont go crazy) Use snake_case (lower case plus underscores) for variables CONSTANT variables must be all upper case and immediately following any import statements Do NOT use functions for this assignment. Modules Allowed You may only import the following modules into your programs and use their methods and attributes, unless first receiving special (and unlikely) permission from your facilitator: math os re string sy """"

the question is : 3.4: Write a Python program does all the following steps: a. Read a file located in the same directory as the program named: cs521_3_4_input.txt o Print a clear error message and end the program if the file is missing o The program must not crash because the file doesnt exist o The input file name must be a constant variable. o Do not include your test input file in your assignment zip container b. Validate that the file contains a single sentence of 20 words. o Print a clear error message and end the program if the file has a different number of words. o Use a constant variable to set the number of words allowed in the file c. Break up the sentence into four lines of five single spaced words o Use a constant variable to set the number of words per line d. Write the lines to a new text file named: cs521_3_4_output.txt o The output file name must be a constant variable. o Automatically overwrite the output file if it already exists e. On success, print Success! Output written to: cs521_3_4_output.txt o Use the output constant, do not hardcode the file name in the print. o This or an error message are all that are printed by this program. o Do not include this output file with your submission. Notes: Do not hardcode your string slices You are not to include any text files from this problem in your zip container There are 4 constant variables in this program Remember to properly close all files. You will lose 0.5 pts for including a text file

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions