Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I am making a runner file titled Proj 0 2 Runner.py ' ' for a python program titled Proj 0 2 . py .
I am making a runner file titled "ProjRunner.py for a python program titled "Projpy
I need to demonstrate a basic knowledge of frequency distributions and histograms with this python program. I need to write code to create a frequency distribution chart that emulates a histogram for a given dataset without access to special libraries. I will not write the code to produce the chart. I will simply write the code to produce the data that will be used by the following
code to produce the chart.
Here is "Projpy:
from ProjRunner import Runner
import sys
import textwrap
print
Expected three numeric commandline arguments."
#Get the commandline arguments and put them in a
#list named args.
args listmapint sysargv:
# Check if the user has entered three commandline arguments
if lenargs:
printMissing commandline arguments"
printUse default values in place of commandline arguments"
args
printThe default values are:args
else:
printThe commandline arguments are:", args
#Use the commandline arguments to create a dataset.
datalist
rangelist
rangelist
rangelist
rangelist
rangelist
rangelist
rangeintargsintargsintargs
printThe dataset is:
wrappedlist textwrap.wrapstrdata width
for line in wrappedlist:
printline
print
Your code may not import anything.
printExecute student code."
#Call student's run function to process the dataset
#and return the result.
result Runner.rundata
print
Display data returned by student code."
#Use the list returned from student's run function to
#display a frequency distribution chart.
#Find the maximum value in the result
maxvalue maxresult
# Loop through each row
for i in rangemaxvalue, :
# Loop through each value in the result
for j in rangelenresult:
if resultj i:
print x end
else:
print end
print
# Print the xaxis labels
for i in rangelenresult:
print end
print
#Print the list returned by the student's run function.
printresult
My main question is if this code is okay here is my ProjRunner.py file code:
#File: ProjRunner.py
class Runner:
@staticmethod #Define static method w in Runner class
def rundataset: #Takes dataset as argument
#Initialize a list 'frequencydistrib',
#length is than the maximum value in dataset
frequencydistrib maxdataset
for value in dataset: #For loop iterates through dataset
#Gets count and increments by adding to current value in 'frequencydistrib'
#Number of times a unique value appears is accounted for
frequencydistribvalue
return frequencydistrib #Returns calculated frequency distribution
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started