Create a script called partI.py. In this script, define the readFile(): will take a string filename as a parameter, and it will return a list.Python Programming

This is a comprehensive quiz to  test and evaluate your knowledge on Python. It  is composed of two  parts and it must be done individually. The purpose of this script is to process files, store them into a data structure (i.e., a list), define functions that will process items, and then report analysis and calculations into a file.

PART I (10 POINTS)

Create a script called partI.py. In this script, define the following functions

 

  1. printOptions(): a function that will display the following message:

>python3 partI.py [-option] [arguments] [-a]: read from argument

[argument l]: name of file desired to read [argument 2]: name of file desired to write [argument 3]: target desired to fin on argument 1

[-i]: interact with user (no arguments needed)

[ -r ] : generate random file

[argumentl] corresponds of filename

[argument2] corresponds to how many numbers to generate [argument3] corresponds to start number

[argument4] corresponds to end number

 

  1. readFile(): will take a string filename as a parameter, and it will return a Each element of the list represent a line from the file filename.

  2. writeToFile(). Will take a string filename as a parameter and a list mylist as a parameter. The purpose of this function is to write in the file "filename ", the contents of

  3. (optional) validateFile(): Will take a string filename as a parameter. The purpose of this file is to check if the filename exists or not . In case the file exists, the function will return True, otherwise will return False

  4. calculateSum(): will take a list of values, mylist containing numeric values. The purpose of this function is to calculate the sum of all the items in the

  5. calculateAverage(): will take a list of values, mylist containing numeric values. The purpose of this function is to calculate the average of all the items in the

  6. findTheLargest():will take a list of values, mylist containing numeric values, and it will return the largest value from the argument s.

  7. findTheSmallest(): will take a list of values, mylist containing numeric values and it will return the smallest value from the argument

  8. count Total Ti me s ( ) : The function will take a target as an argument and a list as argument. Your function will count the total number of times the target appears in the list

  9. f i nd St d De v () : This function will take a list a of numeric values as a parameter. The function shall return the standard deviation Sx of the values in the list Remember that the standard deviation can be calculated as follow:

where:

  • N = the total numbers in the data file

  • x = the mean of x; (also known as the average)

  • x; = Each of the values in the array

 11.genera teRandom () : The function will take 4 arguments:

    • filename: the name of the file where a random number will be appended

    • total: the total number of random numbers to generate randomly

    • st art: the starting random number to be generated

    • end: the ending random number to be generated

 

 

PART II                                                                                                                                                 I

You will need to use part I . pytodevelop Part II. Create a Python script called part II .py.This script will be in charge of interact with the user through two different modes depending on the command provided as the argument when you execute the script as fo llows :

> python3 part II .py [ - o p t i o n ] [ ar gume nt s ]

 

  1. where the option can be one of the three following options:

    1. -a: will read from arguments

    2. - i: will interact from user

    3. - r: will generate a file with random numbers

  2. If the option is -a then you need to provide arguments (two file names)

  3. If the option is -i then you don't need to provide any arguments

  4. If the user did not provide any option, your script shall print the following error message

 

Pl e a s e provide a valid opt i on : python3 partII.py [ - op t i on ] [ ar gume nt s ]

And the function printOptions ()from Part I shall be called displaying the possible options for the program

You should run your program with the command shown in previous section. Where:

 

  • -a: means you will process the information from the command line

  • [argumentl] is the name of the file your program will read

  • [argument2] is the name of the file your program will write the results

  • [argunmet3] is the target interested to find

Attachments:

Instructions Files

Python Programming Experts

expert
Oliver
Python Programming

60 Answers

expert
Issac Torres
Python Programming

67 Answers

View More Experts
Disclaimer

The ready solutions purchased from Library are already used solutions. Please do not submit them directly as it may lead to plagiarism. Once paid, the solution file download link will be sent to your provided email. Please either use them for learning purpose or re-write them in your own language. In case if you haven't get the email, do let us know via chat support.

Get Free Quote!

251 Experts Online