Ezra and I took 30 minutes this evening and wrote a word find puzzle solver in Python. This uses a little bit of pre-processing, sets, dictionaries, tuples, and other (less efficient) techniques to fairly quickly find the answers.
VisPy is quite an interesting tool. They say it is for “scientific visualization”. Here is an example of that. I took a demo from their github page and added a little code to generate a sinewave. The cool thing is that the graph, scaling, panning, zooming, and redrawing all come out of the box.
I previously wrote about installing VisPy. Thanks to the great efforts of some unnamed people, Python on Windows is really working nicely now.
Here is a screenshot:
Here is the code:
VisPy is a Python library for interactive scientific visualization that is designed to be fast, scalable, and easy to use.
Here is how I installed it:
First I installed the latest Python 3.6 on Windows 10 by following the directions on http://www.python.org. Once this was installed, I opened up Windows PowerShell and ran this command:
py -m pip upgrade vispy PyQt5 --user
I found some sample code here, and using NotePad++, copied and pasted it, saving it to Desktop\Code\v1.py
In PowerShell, I changed to the directory that I saved the python code to and ran it:
cd Desktop\Code py .\v1.py
Here is the output:
It’s a pretty smooth and clean looking UI. It seems extremely powerful, but I’ll need to dig in and see what makes it tick…
Here is an example of a moving 2D sine wave using Python 3, PyGame, and PyOpenGL. See a https://blog.gahooa.com/2018/02/11/pygame-and-opengl-on-windows-10/ for how to install them.
This sample program is designed to have a 100×60 unit working area with a 10 unit buffer around the edges. You can see the axis in the lower-left (0,0) where Y+ is up, and X+ is to the right.
The structure of the program was created to make it super easy to work on the “guts” of the graphics without getting it confused with the “bookkeeping” end of OpenGL or PyGame.
Note: the glOrtho() command is how 2D “parallel perspective” is setup. It defines the left, right, bottom, top, near plane, and far plane. Because it is parallel, there is not the notion of a “camera” per-se, but rather section of the plane that should be viewed. Documented here:
Here is the code!
First I went to http://www.python.org and downloaded the latest version of Python for windows. I made sure to select the option to add it to the system path.
Then I opened windows PowerShell (just a nicer term)
py -m pip install pygame --user py -m pip install numpy --user py -m pip install pyopengl --user
(I also installed NoteTab++, a nice text editor)
From there, I went to github and copied one of the examples from https://github.com/pygame/pygame/blob/master/examples/glcube.py and saved it on my desktop as myglcube.py.
In PowerShell, you just type:
cd Desktop py -m myglcube
Here is my example:
(here is the code)
3D Rendering has always interested me, but I’ve never taken the time to mess around with it much.
When I was a kid I used to do stuff like this in Basic. But I didn’t know trig or other similar functions so I was left to basic math and the random functions.
Here is a little turtle program (python) that will make a wrinkled fabric type display.
Hi, this is Eli. One of our school assignments is to completely learn our math tables by heart. We wrote a python program to help us practice with this. This is a program for multiplication tables 1-12.
Ezra and I are learning how to program in python. Dad helped us get the structure of this program right, but we entered into IDLE and debugged it ourselves.
Here is an example of the program in action:
When you activate the program it asks you how many problems you want – you can go from 1 to 144 problems.
When you are done with your problems it tells you how long you took and how many problems you got right and how many problems you got right and how long it took you to answer each problem.
That’s all for now!