Where does the array printout come from? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Where does the array printout come from? (/thread-34464.html) |
Where does the array printout come from? - Mark17 - Aug-02-2021 I like to understand what lines are generating output. Here's some code: nums={} for a in range(25): randnum = np.random.randint(0,100) print(str(a+1)+': '+str(randnum), end=' ') nums[randnum] = nums.get(randnum,0) + 1 #print(nums) plt.hist(nums, bins=50)In the [Jupyter Notebook] output, I get the print line from the for loop. I also get a histogram down below. In between, though, I get two 25-element one-dimensional arrays. The first has counts (by bin) and the second has cumulative percentage (I think) by bin. What causes these two arrays to be printed? RE: Where does the array printout come from? - deanhystad - Aug-02-2021 Something like this? That is the return value of matplotlib.pyplot.hist(). I haven't used it, but I think Jupiter notebook typically echoes return values and you disable this by ending the line with a semicolon.
RE: Where does the array printout come from? - Mark17 - Aug-02-2021 (Aug-02-2021, 05:29 PM)deanhystad Wrote: Something like this? That gets rid of it. Thanks! |