In this table I will compare some basic programming syntax and conventions between the Python and JavaScript programming languages. Programming element Python JavaScript Creating a variable that contains an int: age = 25 var age = 25; Creating a variable that contains a float: probability = 0.62 var probability = 0.62; Creating a variable that … Continue reading Python and JavaScript: A comparison of the language basics
Processing.py: How to calculate the midpoint of a line
To calculate the midpoint of a line, use the following formula to calculate the x and y midpoints: # Middle of line # midpoint = (xM, yM) xM = (x1 + x2)/2 yM = (y1 + y2)/2 Then the midpoint coordinates (xM, yM) can be used to draw an ellipse on the line. For example: … Continue reading Processing.py: How to calculate the midpoint of a line
WordPress: How to create a Table of Contents page with Python
What I wanted to create was a dynamic Table of Contents page where I could have a listing of all of my published articles, organized by category, and sorted such that categories with the most posts appear first, and the posts under each category are listed from most recent at the top to oldest at … Continue reading WordPress: How to create a Table of Contents page with Python
WordPress: How to use an iframe to pull in outside content
Here are instructions for using an iframe with wordpress.org websites. 1. Download the iframe Plugin from here. 2. Use a shortcode in a post like this: Note: I added a space after the left bracket [ and before the right bracket ] in order to not trigger the shortcode in the below code example. Summary:Using … Continue reading WordPress: How to use an iframe to pull in outside content
Python on the web: How to get a list of all available Python modules
If you want to get a complete list of Python modules available on your web host, you can do so with the following code: I saved the above code as a CGI script called “available_modules.py” and uploaded it to my website cgi-bin. Here is what the code produces, shown below in an iframe: For more … Continue reading Python on the web: How to get a list of all available Python modules
Python: How to print function details iteratively using inspect and getmembers
As described in a previous post, the help() function is great for seeing details about any given module function, one at at time. Python: How to use the built-in help( ) and dir( ) functions For example: print help(imageio.mimsave) However, sometimes we want to see details for all of the functions in an imported module. … Continue reading Python: How to print function details iteratively using inspect and getmembers
Processing.py: How to create grid square patterns and digital camo
Continuing the Processing.py series, this article demonstrates how to use a slight variant of the 10 PRINT example to build a grid pattern design made up of squares of differing sizes and colors. This technique can also produce digital camo (camouflage) patterns! For the previous entry in the Processing.py series, see this page: Processing.py: How … Continue reading Processing.py: How to create grid square patterns and digital camo
Processing.py: How to implement 10 PRINT
Continuing the Processing.py series, this article demonstrates how to implement ’10 PRINT’ to create interesting line images. 10 PRINT is an old Commodore 64 one-line program written in BASIC that looks like this: 10 PRINT CHR$(205.5+RND(1)); : GOTO 10 For more information, see 10print.org. For the previous entry in the Processing.py series, see this page: Processing.py: … Continue reading Processing.py: How to implement 10 PRINT
Processing.py: How to use shapes, placements, and colors
To continue the series of how to use Processing.py, this article demonstrates how to use basic shapes, placements and colors. For the previous entry in the Processing.py series, see this page: Processing.py: How to draw lines and use mouse events This code demonstrates the use of lines, rectangles, ellipses, colors and placements by sketching a … Continue reading Processing.py: How to use shapes, placements, and colors
Python: How to generate animated .gifs
The below code can take in a list of consecutive image files and stitch them together to create an animated .gif file. It requires the imageio module. The path to the consecutive image files is set in the image_path variable. The full path to the name of the .gif file to be built is passed … Continue reading Python: How to generate animated .gifs