Python program does not display correctly on 10.13, but works on old MacBook
I currently have the Anaconda version of Python 3.5.4 installed on 10.13.4 and python3 test.py at the shell prompt gave me the expected result.

I can only suggest that you have a broken tk/tcl install somewhere. This is probably due to the problems mentioned on this page. I would suggest uninstalling all versions of Python 3 and then installing either the Anaconda version or the Homebrew version. I prefer the Anaconda version as it allows me to easily install Jupyter and they look after these sort of compatibility problems well.