Q:

Showing histogram code never ends

I created and ran a very simple python code to show a histogram. The histogram shows successfully but the program never finishes. Could you please help?
By clicking Ctrl and C, the following message shows up.
File "hist_ex.py", line 9, in <module>
plt.show()
File "/Users/myusername/.pyenv/versions/anaconda3-4.4.0/lib/python3.6/site-packages/matplotlib/pyplot.py", line 254, in show
return _show(*args, **kw)
File "/Users/myusername/.pyenv/versions/anaconda3-4.4.0/lib/python3.6/site-packages/matplotlib/backend_bases.py", line 218, in show
cls.mainloop()
File "/Users/myusername/.pyenv/versions/anaconda3-4.4.0/lib/python3.6/site-packages/matplotlib/backends/backend_tkagg.py", line 1078, in mainloop
Tk.mainloop()
File "/Users/myusername/.pyenv/versions/anaconda3-4.4.0/lib/python3.6/tkinter/__init__.py", line 557, in mainloop
_default_root.tk.mainloop(n)
KeyboardInterrupt

And here is my python code.
import numpy as np
import matplotlib.pyplot as plt

x = np.random.normal(50, 10, 1000)

plt.hist(x)
plt.show()

A:

this is happening because you are in non-interactive mode...
https://matplotlib.org/api/_as_gen/matplotlib.pyplot.show.html
try using 
plt.show(block=False)

