Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in python only use import math,os,random,re , sys only those this is the file we reading from example output file name: data from file..... Column

in python only use import math,os,random,re , sys only those

image text in transcribed

this is the file we reading from

image text in transcribed

example output

file name:

data from file.....

Column 1

value = 9 is the number of numbers that appear in the column

do sum , min , max , avg,sd and frequency

column 2

value = 7 is the number of numbers that appear in the column

do sum , min , max , avg,sd and frequency

a. (3 points) Check whether there are any supplied arguments from the command line. Print "Usage: python stats.py [FILE]" if there is none and terminate the program. b. (7 points) Open each file in the list of arguments. For any file that cannot be opened, print "Cannot read \{file name\} - skipped" where {file name } is the name of the file that cannot be opened, then continue down the next file in the list. For any file that can be opened but is empty, print "Empty - skipped" then also continue down the next file in the list. Print a horizontal line "_-_._-_.-_.-_" for every file that has been processed, including those that have been skipped. c. For each file that can be opened and is not empty, do the following in order: i. (5 points) print the file name in the first line and its content in the next lines. ii. (15 points) for each column, print "Column {n} " where {n} denotes the column number starting from 1; and in the next line, print "- \#values: {a} " where {a} is the number of valid values (i.e., not blank). If the number of valid values is positive, continue to print the following stats from the values in the subsequent lines: 1. "- sum: {b} " where {b} is the sum of the values. 2. "- min:{c} " where {c} is the minimum value. 3. "- max:{d} " where {d} is the maximum value. 4. "- avg: {e} " where {e} is the average value. 5. "- SD: {f} " where {f} is the standard deviation of the values. iii. (10 points) continue from the previous bullet. If the column contains some valid values, also print "- Frequency" after "_ SD: {f} ". Then, in the subsequent lines, print " { value\} : \{freq } " for each value in the list of valid values in the column, in an ascending order, where { value } is the value and { freq } is the number of times it appears in the column. 2,55,57,6,35,47,9,83,2,96

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

Spomenik Monument Database

Authors: Donald Niebyl, FUEL, Damon Murray, Stephen Sorrell

1st Edition

0995745536, 978-0995745537

More Books

Students also viewed these Databases questions