I have always strived to make some of my programming assignments relevant to what my students are learning in other classes. To that end, many of the tasks I give students are drawn directly from the work they are doing in math, science, and history courses. I want them to appreciate computer science as a tool they can use to solve problems. The examples I have included below feature Python solutions but can be adapted to the language of your choice.

Talk to your colleagues, talk to your students

In the hallways, at lunch, or even in the parking lot, find some time to chat with other teachers and see what topics they are covering in their classrooms. Most teachers will be happy to provide you with copies of worksheets and other assignments they are currently using. They should welcome your efforts to supplement learning with additional practice. Speak to your students when they are in your room or passing in the hallways between classes. Ask them what they are doing currently in geometry, algebra, or chemistry classes. Often, they will be encountering formulas or lab data that needs to be interpreted.

Math assignments

It has been my experience that math classes tend to have the most obvious problems that can be solved by computer science. Grab any trigonometry, calculus, or geometry textbook and you will find dozens of equations that can be assigned in a programming class. A student who can write an effective program will gain a deeper understanding of the math equation than one who just completes exercises for their homework.

The distance formula

Virtually all sophomore students at my school are enrolled in geometry. Early in the semester they are shown in my CS class how to create variables and request input from the keyboard. To expand on this basic lesson, I had all of my students write programs to calculate the distance formula as a way to introduce the use of the math library in Python. I show my students that unlike a scientific calculator, a computer keyboard does not have a square root key or a key labeled X2. Rather, students have to be shown how to express mathematical equations using the proper commands to obtain an accurate result.

Below is code sample from one of my students:

y1=input ("Enter Y1   ")
x1=input ("Enter X1   ")
y2=input ("Enter Y2   ")
x2=input ("Enter X2   ")
print ("%.2f" %d)


You may notice that my student included code to format the output to two decimal places. This was a feature that had been introduced in an earlier lesson. The most frequent errors I encountered were with order of operations. Students had to be careful to use parentheses and check their results to verify that they were correct. Many students assume that a computer (or a calculator) output is always right.

Even with this simple program, ample opportunities exist to extend the code to become more flexible and powerful. You could add a while loop to make the program continue to execute until a particular value is input. Perhaps your students can create a graphical interface for program input or have output that would place points on a graph and trace the distance. Once students have mastered a number of formulas, give them the task of creating a menu so that a user can choose the type of equation they need to solve.

Evaluating triangles

How do you determine if a triangle can be formed when given three side lengths?

The above question was posed in every geometry classroom in my school. I gave my CS students an assignment to write a program to determine if three side lengths were able to construct a valid triangle. We had just begun to learn how to use if statements so naturally this seemed to be a great way to include them as part of the resulting programs.


Right Triangle                                                    Acute Triangle                                                             

           Sample code fragment from a student:

#determine if the values are valid for a triangle
#exit program if values are not valid
if A+B<=C:
            print "You do not have a valid triangle!"
if (A**2)+(B**2)==(C**2):
            print "This is a right triangle"
elif (A**2)+(B**2)>(C**2):
            print "This triangle is acute"
            print "This is an obtuse  triangle"


Chemistry programs

As a co-teacher in chemistry classes, I have had many opportunities to showcase how computer science can be a useful addition to periodic tables and Bunsen burners. Equations to determine percent composition, molar mass, and conversions between different units of measurements are all excellent candidates for coding projects.

Image source: http://tmplt65.myfreeip.me/ideal-gas-law/

Code fragment from student program to convert units of pressure in chemistry class:

print "Now the program will convert kilo Pascals to other units"
print "Enter the value of kPa at the prompt  "
k = input ("Enter the number of kPa    ")
print "The number of atm is   "
print k/101.3
print ""
print "The value of mmHg of torr is"
print (k/101.3)*760
print ""


Data analysis

Not every class demands that you write custom programs. Sometimes you want to use a computer for data collection and visualization. This past fall, I attended a professional development session at University of Massachusetts Lowell. While we spent our morning coding Arduino based robots, all of the participants got to spend time working with the web based iSenseProject.

Our session was led by one of the project directors, Fred Martin, Associate Professor of Computer Science and Director of Student Success at the University of Massachusetts Lowell. We were also joined by a number of graduate and undergraduate students. Using digital scales to determine mass and graduated cylinders to determine volume, my cohort participated in Project #709, Density of Objects.

Multiple Data Sets.png

While we used crayons in our lab, students in my school study density in chemistry, earth science, and other courses. Once your data is entered, you can use a variety of visualization tools to explore your information. The interface is very easy to manipulate and teachers have the opportunity to compare results from different class periods. Professor Martin explained that the design of iSense uses a similar approach to what Google Docs does for sharing information among many people.

History class website

Humanities courses can also provide opportunities for CS students to showcase their skills. One of my students enrolled in an American history class was assigned to do a presentation on a famous American sports figure from the 1920s. He decided to create a website on Babe Ruth. His teacher was pleased since it was a departure from the typical poster board or PowerPoint presentation. My student appreciated the opportunity to showcase the skills he had been learning in my Exploring Computer Science class.

What steps do you use to make your programming assignments leverage what your students are doing in other content areas? Please share your comments and ideas.


Neil Plotnick (nplotnick@everett.k12.ma.us) works at Everett High School, an urban district located just north of Boston. In 2015, he was a recipient of the Presidential Award for Excellence for Math and Science Teaching (PAEMST). He has taught Exploring Computer Science and was a pilot site for the AP Computer Science Principles course developed by Code.org during the 2015-16 academic year.