Answered step by step
Verified Expert Solution
Link Copied!

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 "Proj02Runner.py'' for a python program titled "Proj02.py".
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 "Proj02.py":
from Proj02Runner import Runner
import sys
import textwrap
print("
Expected three numeric command-line arguments.")
#Get the command-line arguments and put them in a
#list named args.
args = list(map(int, sys.argv[1:]))
# Check if the user has entered three command-line arguments
if len(args)!=3:
print("Missing command-line arguments")
print("Use default values in place of command-line arguments")
args =[6,10,4]
print('The default values are:',args)
else:
print("The command-line arguments are:", args)
#Use the command-line arguments to create a dataset.
data=list(
range(0,11))+list(
range(1,10))+list(
range(2,9))+list(
range(3,8))+list(
range(4,7))+list(
range(5,6))+list(
range(int(args[0]),int(args[1])))*int(args[2])
print("The dataset is:")
wrapped_list = textwrap.wrap(str(data), width=50)
for line in wrapped_list:
print(line)
print("
Your code may not import anything.
")
print("Execute student code.")
#Call student's run function to process the dataset
#and return the result.
result = Runner.run(data)
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
max_value = max(result)
# Loop through each row
for i in range(max_value, 0,-1):
# Loop through each value in the result
for j in range(len(result)):
if result[j]>= i:
print(" x ", end="")
else:
print("", end="")
print()
# Print the x-axis labels
for i in range(len(result)):
print("---", end="")
print()
#Print the list returned by the student's run function.
print(result)

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