Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON ONLY Purpose This purpose of this comprehensive program is 1. to become comfortable with the constructs we have learned so far including function, iterations,

PYTHON ONLY

image text in transcribed

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Purpose This purpose of this comprehensive program is 1. to become comfortable with the constructs we have learned so far including function, iterations, conditionals, lists, and files. 2. to identify any gaps in your learning and the concept. - Your task is write the following functions: 1. - takes filename as a parameter. The function creates an empty file. - An example is shown below: - create_file("myfile.txt") File myfile.txt should now be visible in the working directory 2. read_file - takes filename as a parameter and returns a string with file content. - An example is shown below, for the file myfile.txt assuming it has two separate lines, which are "This is The Pennsylvania " and "State University". read_file("myfile.txt") Output: "This is The Pennsylvania State University" 3. - This function takes filename as a parameter. and returns a list whose elements are representative of the lines in the file. - An example is shown below, for the file myfile.txt assuming it has two separate lines, which are "This is The Pennsylvania " and "State University". - read_file_lines("myfile.txt") Output: ['This is The Pennsylvania ', 'State University ] 4. - takes filename and a list as a parameter. This function overwrites the file using list element-by-element where each element is on the newline into the file. It is necessary to check if the list is empty before start inserting elements to file. If the list is empty, print "list is empty" and perform no operations. An example is show below, for the file myfile.txt assuming it has two separate lines, which are "This is The Pennsylvania " and "State University". - write_to_file("myfile.txt", ["University Park", "PA USA"]) File myfile.txt now looks like the following:- - takes filename and a list as a parameter. This function writes the entire list element-by-element into the file. It is necessary to check if the list is empty before start inserting elements to file. An example is show below, for the file myfile.txt assuming it has two separate lines, which are "This is The Pennsylvania " and "State University". - append_to_file("myfile.txt", ["University Park", "PA USA"]) File myfile.txt now looks like the following: myfile.txt x 1 This is The Pennsylvania 2 state University 3 University Park 4 PA USA 5 Return values must be assigned to variables before used. You are NOT allowed to use the following constructs unless specified in the assignment directions. Using the following constructs will result in 0 (zero) for the entire submissio (assignment, timed test, etc.). The restricted items are as follows: - Concepts not discussed in lectures yet - String functions - Member functions - Exceptions (can use) : Ien () and x=x+[y1,y2,y3] - Built-in functions \& types - Exceptions (can use): str( ), readline(), open( ), close( ), write( ), read( ), range( ), split( ) - Cannot use .append, sort, etc. - Cannot use "Slicing" - Cannot use "list comprehension" - Cannot use "not in" (together) - Cannot use "in" - not allowed with conditionals - Exception (can use): with range () - Cannot use and \{\} - Exception (can use): mathematical operations (multiply \& exponents) - Data type functions - Exceptions (can use): int(), str (), float () - Break - Continue - Nested Constructs - Exceptions (can use): 2-D list - Multiple returns \& Multiple assignments - Recursion (not allowed unless the question explicitly states otherwise) - Functions within functions (Definitions) -- invocation is fine - Default Parameters - Global variables - Keyword as variable names - while true or without proper condition

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

Students also viewed these Databases questions

Question

What is a knowledge management system?

Answered: 1 week ago

Question

1. Identify what positions are included in the plan.

Answered: 1 week ago

Question

2. Identify the employees who are included in the plan.

Answered: 1 week ago

Question

7. Discuss the implications of a skill-based pay plan for training.

Answered: 1 week ago