Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The code at the bottom tries to display a primitive histogram on the console bas

ID: 3876797 • Letter: T

Question

The code at the bottom tries to display a primitive histogram on the console based on integers typed on the console by the user. Here is an example of how it might work:

1234543234
----------- Histogram ----------------

Find the mistakes in the code and add the appropriate doc-string. The mistakes are simple, so no need to rewrite the program, rather practice debugging.

Make a list briefly mentioning every change you make to the program. For example, you might have a list that starts like this:

##############CODE#############

Explanation / Answer

def get_data(n, data):
data = []
for i in range(n):
data.append(input('Enter one integer only:'))
return data

def find_min_and_max(data, the_min, the_max):
the_min = min(data)
the_max = max(data)


def counting(data):
the_min = min(data)
the_max = max(data)
#ind_min_and_max(data, the_min, the_max)

s =int(the_max)+1
frequency = [0]*s
i=int(the_min)
while(i<int(the_max)+1):
frequency[i]=0
i +=1
for d in data:
#j = d - the_min + 1
frequency[int(d)] += 1

return frequency


def draw_histogram(frequency, the_min, the_max):
print(" ----------- Histogram ---------------- ")

for f in frequency:
print(f, '*'*f)


data_size = int(input('How many data values?'))
data = get_data(data_size, [])
frequency = counting(data)

for i in range(len(frequency)):
if (frequency[i] != 0):
print(i,":",end="")
for j in range(frequency[i]):
print("*",end="")
print()
  
#draw_histogram(frequency,0,0)

output:

How many data values?10
Enter one integer only:1
Enter one integer only:2
Enter one integer only:3
Enter one integer only:4
Enter one integer only:5
Enter one integer only:4
Enter one integer only:3
Enter one integer only:2
Enter one integer only:3
Enter one integer only:4
1 :*
2 :**
3 :***
4 :***
5 :*
>>>