# 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:

## A. ODDS, EVENS & NATURALS — CONCEPT MAP

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 natural numbers.

5. Explain how the code works.

#### COMPARE PYTHON & SCRATCH

6. See/run the Scratch code at scratch.mit.edu/projects/472091993/editor

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

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

9. 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)

(b)

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

#### CODE EFFICIENCY

10. Compare the Python code and the Scratch code for listing number patterns.

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

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

#### SUMS WITH PYTHON

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

12. Run the code to see this output:

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

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

15. Edit the code to list the first 25 natural numbers and their sums.

16. What patterns do you notice?

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

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

19. 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.

20. How do even numbers grow compared to how the sums grow?

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

## 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.

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

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

24. 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 odds.

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

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

27. Run the code to see the new output.

28. 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.

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

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

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

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

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

34. Run the code to see the new output.

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

36. 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 to create the above graph is Google’s CoLab.

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

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

36. Which part is similar?

39. 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.

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

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

# G. REFERENCE VIDEOS

#### Odds & evens

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