« Middle School Courses
This course is included with our Coding/STEAM Curriculum - Middle School Plan

Lesson Plan

Lesson: Math Operators

Time: 40+ mins

Introduction

In this lesson, students will learn to use Python math operators such as addition, subtraction, and division. Additionally, students will practice writing mathematical expressions throughout the modules.

Vocabulary

  • Operator: A symbol that modifies or combines values. For example, + and - are operators that add or subtract values.
  • Expression: A sequence of values or variables connected by operators. For example, the expression b - a + 1 subtracts two variables and then adds the value 1.
  • Binary Operator: An operator that only combines two values. Most of the operators that are commonly used in mathematical expressions like / and * are binary operators as the operation only involves the number before and after the operator.
  • Modulus: The modulus operator is a binary operator that divides the first number by the second number and returns the remainder from that division operation. If the second number is a factor of the first number, the modulus operator will return 0.
  • Incrementing: In programming, incrementing is the process of replacing a variable with the result of an operation and itself that increases the value stored in the variable. For example, x = x + 1 increments the value stored in x by 1.
  • Decrementing: In programming, decrementing is the process of replacing a variable with the result of an operation and itself that decreases the value stored in the variable. For example, x = x/2 decrements the value stored in x by half of itself.

Objectives

Students will...
  • Write and apply mathematical expressions
  • Apply coding concepts to convert integers to floats
  • Use the exponent and modulus operators
  • Increment and decrement values stored in variables
  • Simulate real world mathematical equations with Python

Materials

  • Computers (1 per student) with student account access to Tynker.com

Warm-Up (5 minutes)

Ask students to solve the following:
   1. 10 + 15 - 1 = ?
   2. 4 / 2 = ?
   3. 5 * 10 / 2 = ?
   4. (2 + 2) * 10 / 5 = ?

Answers:
   1. 24
   2. 2
   3. 25
   4. 8

Activities (35 minutes)

Facilitate as students complete the Math Operators modules on their own:
1. Addition and Subtraction (Tutorial)
    • Students will read a short document that explains the addition and subtraction operator in Python.
    • Optional: Before students select the “play” button, ask them to write down what they think the code will output.
    • Do students need help with the “100th Birthday” puzzle? Give a hint: Tell them use the code listed above as a reference.
2. Multiplication and Division (Tutorial)
    • Students will read a short document that explains the multiplication and division operator in Python.
    • Optional: Ask students, “What is a binary operator?” (An operator that combines two values)
    • Optional: Before students select the “play” button, ask them to write down what they think the code will output.
    • Do students need help with the “Distance, rate, and time” puzzle? Give a hint: Tell students that they will need to divide by 60.
    • Do students need help with the “Troll call” puzzle? Give a hint: Tell students that a troll’s name is “tr” concatenated with “ol” repeated “age” times.
3. Floats (Tutorial)
    • In this module, students will expand on what they learned in the previous lesson about floats.
    • Check that students are using floats in their puzzle solution.
4. Float Function (Tutorial)
    • Students will read a short document that explains the float function, which returns its argument as a floating point number.
    • Are students struggling with the puzzle? Tell students that they will need to convert values between decimal and integer representations. Optional: Tell students to include this in their code: str(int(applicants * percentage / 100.0))
5. Exponents (Tutorial)
    • In this module, students will learn about exponents and the exponent operator (**).
    • Students who are not strong at math are likely to struggle with the “Volume versus surface area” puzzle, so encourage students to brainstorm possible solutions with a partner.
6. Modulus (Tutorial)
    • In this module, students are introduced to the modulus operator (%), which returns the remainder after dividing the number on the left by the number on the right.
    • Optional: Before students select the “play” button, ask them to write down what they think the code will output.
    • Are students struggling with the “Variable precision” puzzle? Tell them to use the code in the examples above as a reference.
7. Order of Operations (Tutorial)
    • In this module, students will read a short document that reviews the order of operations.
    • Optional: Before students select the “play” button, ask them to write down what they think the code will output.
8. Increment and Decrement (Tutorial)
    • Students are introduced to incrementing and decrementing.
    • Optional: Before students select the “play” button for the incrementing and decrementing examples, ask them to write down what they think the code will output.
    • Say, “When a variable is replaced by a smaller value, the process is called ‘decrementing.’” Emphasize that its previous value is decreasing.
    • This module does not contain puzzles.
9. More on Increment and Decrement (Tutorial)
    • In this module, students will learn how to use incrementing and decrementing with other operators.
    • The puzzle solutions in this module requires students to write multiple lines of code, so encourage them to work together as they solve the puzzles.
10. Fibonacci Sequence (Tutorial)
    • This module introduces students to Fibonacci numbers and the golden ratio.
    • Optional: Do a quick Google Images search of “golden ratio in nature” and show your students how mathematically beautiful nature can be!
    • Are students struggling with the puzzle? Give a hint: Tell them to include 7 additional variables to solve the puzzle.
11. Quiz
    • In this quiz, students will solve 3 different math operators puzzles.
    • In each problem, students will need to correctly apply math operators to produce the expected result.

Discussion Questions/Follow-Up Activities (20 minutes)

    • Ask students what they learned about using math operators in Python.
    • Who can give an example of a math operator and explain how they applied it in today’s lesson?
    • Have students create their own math operator problems and test it out using Python.

US Standards

  • CCSS-ELA: SL.8.1, RI.9-10.3, RI.9-10.6, RI.11-12.3, RI.11-12.6, L.9-10.3, L.9-10.6, L.11-12.3, L.11-12.6
  • CCSS-Math: HSN.Q.A.1, HSN.Q.A.2, HSN.Q.A.3, MP.1, MP.2, MP.4
  • CSTA: 2-AP-11, 2-AP-13, 2-AP-17, 3A-AP-17, 3B-AP-11
  • CS CA: 6-8.AP.11, 6-8.AP.13, 6-8.AP.17, 9-12.AP.12, 9-12.AP.16
  • ISTE: 1.c, 1.d, 4.d, 5.c, 5.d
This course is not part of your plan. Please upgrade to view all answer keys

Class Presentations

These student-facing slide presentations help educators seamlessly run Tynker lessons in a virtual or physical classroom setting. Each lesson has its own set of slides that introduce the big ideas, suggest unplugged activities, and include a section for each activity module. While running lesson slides, you can switch back and forth between the activity, the slides, answer keys and other lesson materials.
A sample slide presentation is available for your review. Please log in to view all the class presentations available with your plan..
Lesson 1
Welcome to Python
32 Slides
Lesson 2
Variables and I/O
29 Slides
Lesson 3
Data Types
29 Slides
Lesson 4
Math Operators
32 Slides
Lesson 5
Boolean Logic
35 Slides
Lesson 6
Turtle Graphics
31 Slides
Lesson 7
Branching
27 Slides
Lesson 8
While Loops
27 Slides
Lesson 9
Strings
32 Slides
Lesson 10
Lists
28 Slides
Lesson 11
For Loops
24 Slides
Lesson 12
Functions
28 Slides
Lesson 13
Dictionaries
20 Slides
Lesson 14
Classes and Objects
24 Slides
Lesson 15
Recursion
20 Slides