Earn Higher Grades With Instant Assignment Help.Ask Question!

Python Programming
(5/5)

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.

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

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:
(5/5)

Related Questions

CSI 1420 Introduction to C Programming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two majorconstructs of the C programming language – Fu

The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Assignment To Be Done By Our ExpertsGet A+ Grade Solution Guaranteed

expert
joyComputer science
(4/5)
12 Answers Hire Me
expert
Robert DLaw
(4.8/5)
747 Answers Hire Me
expert
Dr Samuel BarberaStatistics
(5/5)
934 Answers Hire Me
expert
Tutor For YouEconomics
(5/5)
893 Answers Hire Me