Coding in Chemistry


Computer coding has been getting a lot of attention with the Hour of Code movement and President Obama’s recent “Computer Science for All” initiative. Just like it is no longer solely the job of the English teacher to teach language and communication skills, it is no longer solely the job of the computer science teacher to teach programming skills. According to, 71% of new STEM jobs are in computer science fields but only 8% of STEM graduates major in computer science. Unfortunately, only 1 in 4 schools offers computer science. As STEM educators, we are on the front lines to bridge that gap. So how do we integrate coding into the chemistry classroom in a meaningful and time-efficient way? Here are some ideas to get you started that have been tested in my classroom:

1. Model 3D particles using VPython and Glowscript

If you use the AMTA Modeling Instructional materials (or even if you do not), you are probably familiar with using particle models to represent density. The only drawback of particle models is they are two-dimensional. Glowscript is a free integrated development environment (IDE) that uses the VPython language. With one simple line of code, students can create a hard sphere particle. They can then manipulate that code to change the size and position of their particle. Students can create many particles and ultimately change the density of their substance by either changing the size and/or spacing of their particles. This activity is great as an introduction to programming and it helps students develop spatial reasoning skills by using a 3D coordinate system. You can even program these particles to move!

2. Create all sorts of calculators using Python and Cloud9

Chemistry is a very math-heavy subject and requires students to use advanced problem-solving skills. Many times students can solve specific problems but have trouble generalizing the process. Coding a calculator allows students the opportunity to generalize functions they may have thought were simple.

Python is a very straight-forward coding language that allows for anyone to pick up the basics. As a teacher, I suggest spending some time on to learn the basics of variables, operands and if/then statements. You certainly do not have to complete the whole course to learn enough Python for this application. I have my students spend a class period on Code Academy to familiarize themselves with Python but I do not think that time is a necessity.

Additionally, Cloud 9 is a really nice IDE for coding many programming languages wherever there is internet.

I have students use Python to make mole calculators as well as stoichiometry calculators. The gas laws would also lend themselves well to a coding project. You could even replace a worksheet with a coding challenge if you are feeling short on time.

With IDE’s like GlowScript, Cloud9 and many others, coding is now accessible to everyone. My goal for next year is to have students coding chemistry apps. How are you helping to close the STEM gap?