MATH + CODING WORKSHOP 7-9

(c) George Gadanidis, 2021

Designed to serve as a base lesson plan for diverse learning settings (f2f, hybrid, online, parents/children).

Although designed with the Ontario 7-9 math curriculum in mind, this workshop would be of value to all educators interested in learning how to integrate math + coding.

Based on these resources:

WORKSHOP OVERVIEW

9 EXPECTATIONS

A. ODDS, EVENS & NATURALS — CONCEPT MAP

LOW FLOOR allows engagement with rich math ideas, with minimal prerequisite knowledge.

HIGH CEILING offers access to more complex connections and more varied representations.

The Venn diagram below shows a low floor, high ceiling mapping of the topic of odds, evens & natural numbers.

You can also see the Venn diagram as a mapping of the topic of linear & non linear relationships.

The opportunity to see one idea (odd & even patterns) as another (linear and non-linear relationships), and across multiple representations (concrete, numeric, visual, graphical, algebraic, with code) helps anchor and develop conceptual understanding.

B. ODDS, EVENS & NATURALS — HANDS-ON

CONCRETE/VISUAL REPRESENTATIONS

1. Can you see odds, evens & naturals in the images below?

A.

B.

C.

2. Match each of the images above with 3 of the numeric / algebraic representations below:

  • A. 1 + 3 + 5 + 7 + …
  • B. N
  • C. N(N+1)
  • D. 1 + 2 + 3 + 4 + …
  • E. 2N-1
  • F. 2 + 4 + 6 + 8 + …
  • G. 2N
  • H. N(N+1)/2
  • I. N x N

C. ODDS, EVENS & NATURALS — WITH CODE

In this section, we will use a Python coding environment, provided by the University of Waterloo, to represent number patterns with code.

Listing number PATTERNS WITH PYTHON

1. Go to cscircles.cemc.uwaterloo.ca/console and enter the Python code below.

2. Run the code to see this output:

3. Edit the code to list the first 10 even numbers.

4. Edit the code to list the first 10 odd numbers.

5. Edit the code to list the first 10 natural numbers.

6. Explain how the code works.

Notice that only a couple of lines of code, which are easy to edit, give immediate/dynamic feedback

COMPARE PYTHON & SCRATCH

7. See/run the Scratch code at https://scratch.mit.edu/projects/472091993/editor

8. Edit the code to list the first 10 odd numbers.

9. Edit the code to list the first 10 natural numbers.

10. Explain how the code works.

DEFINED COUNT

The code blocks listed below (a) initialize and (b) increase the value of a variable called “counter“.

(a)

initialize the value of “counter”

(b)

increase the value of “counter”

This is an example of what is referred to as “defined count“.

CODE EFFICIENCY

11. Compare the Python code and the Scratch code needed to list number patterns.

  • Which code more efficient?
  • In what way?
  • Justify your reasoning.

D. SUMS OF ODDS, EVENS & NATURALS — WITH CODE

SUMS WITH PYTHON

1. Go to cscircles.cemc.uwaterloo.ca/console and enter the Python code below.

2. Run the code to see this:

3. Edit the code to list the first 10 even numbers and their sums.

4. Edit the code to list the first 10 odd numbers and their sums.

5. Edit the code to list the first 10 natural numbers and their sums.

6. What patterns do you notice?

7. Notice line 4 in the Python code. What does “=” mean in this case?

8. How is this different from how we use “=” in math?

9. Explain how the code works.

LINEAR & NON-LINEAR GROWTH

Linear means that a pattern has a constant rate of change, like how the height changes as you climb a staircase.

Non-linear means that the rate of change is not constant.

10. How do even numbers grow compared to how their sums grow?

11. What do “linear” and “non-linear” mean in this context?

What did you learn so far?

How did you feel?

What else do you want to know?

E. PLOTTING NUMBERS & SUMS — WITH SCRATCH

PLOTTING NATURALS & EVENS

The Scratch code below plots natural and even numbers.

Notice that the code uses 2 subprograms, called naturals and evens.

Subprograms make code easier to read and understand. They can also make code more efficient.

1. Go to https://scratch.mit.edu/projects/562609789/editor to see and run the program. The output should look as shown below.

2. Looking at their graphs, are the natural and even numbers linear or non-linear patterns? Justify your reasoning.

3. Rename the subprogram evens to be called odds.

  • click on My Blocks in the left menu

  • right-click the evens block, and select edit to rename it

4. Edit the code to plot odd rather than even numbers.

5. Are odd numbers a linear or non-linear pattern?

6. Run the code to see the new output.

7. Study the code. Explain how it works to plot the number patterns.

PLOTTING NATURALS & THEIR SUMS

The Scratch code below plots natural numbers and their sums.

Notice that the code uses 2 subprograms, called number and sum.

1. Go to https://scratch.mit.edu/projects/562614438/editor to see and run the program. The output should look as shown below.

2. Which natural numbers and sums are actually plotted on the graph?

7. Edit the code as shown below. How do the graphs change? Why?

3. Looking at their graphs, are the natural numbers and their sums linear or non-linear patterns? Justify your reasoning.

4. Edit the code to plot even numbers and their sums.

5. Run the code to see the new output.

6. Are even numbers and their sums linear or non-linear patterns?

7. Study the code. Explain how it works to plot the number patterns.

DATA ANALYSIS

In the above activities, you used Python and Scratch code to list and to plot patterns related odd, even and natural numbers and their sums.

Representing the patterns as numeric and graphic data, along with the ability to edit the code and dynamically see what changes, is a powerful form of data representation and data analysis.

Based on this data analysis, what decisions can you make about the nature of the graphs of odd, even, natural numbers, and their respective sums?

F. PLOTTING NUMBERS & SUMS — WITH PYTHON

The Python coding platform used here is Google’s CoLab.

This platform uses a Notebook version of Python, where you have both text cells and coding cells. So in effect, you keep a notebook where some of your cells are live code and some are text, graphics and video, to help you elaborate.

Scientists use these types of Python Notebooks (known more generally as Jupiter Notebooks) to write about their research, and make their findings and analysis (the coding behind the numbers in their data) public, so other scientists may verify and extend their work.

Students need to log in with a Google email address to access all the features of coding platform (create and save their own Python programs). 

Here is the link to this code: https://colab.research.google.com/drive/1LfbK-USfaVoO6IyaGR-FSpITUup-1E1d?usp=sharing

1. How is the Python code shown above different from or similar to Scratch code and the Python code we used previously?

2. Which part is similar?

3. How is the output different?

  • The output self-adjusts to fit the graphing window.
  • Lists are used to store data, and then the graph is created for the lists.

4. Edit the code to plot odd numbers and their sums.

5. Edit the code to plot natural numbers and their sums.

What did you learn so far?

How did you feel?

What else do you want to know?

G. REFERENCE VIDEOS

WHY MATH + CODING?

The affordances of modelling math with code (6 min.)

Odds & evens

Lyrics based on teacher comments after investigating odd and even patterns.