Slope and Y-Intercept

 ECT Lesson Plan: Slope and Y-Intercept


Lesson plan at a glance...

Core subject(s)

Mathematics

Subject area(s)

Algebra

Suggested age

12 to 15 years old

Prerequisites

Basic Python (Introduction to Python);

Lines defined by two points;

Slope intercept form (y = mx+b)

Time

Preparation: 27 to 37 minutes

Instruction: 80 minutes

Standards

Core Subject: CCSS Math

CS: CSTA

In this lesson plan…

Lesson Overview

Students will calculate the slope (m) and y-intercept (b) of a line passing through a given set of points and use Python to solve various challenging slope and y-intercept exercises. Students will improve their computational thinking by finding patterns between the slope and y-intercept of the line, identifying how these values relate to the equation y = mx+b, decomposing tables of values, identifying the increase in y for each unit increase in x, and developing an algorithm that takes a set of points and solves for the equation of the line.

Materials and Equipment

  • For the teacher:
  • Required: Presentation set-up
  • Internet-connected computer
  • Projector and projection screen or other flat projection surface
  • For the student:
  • Required: Internet-connected computers (1 computer per student recommended)
  • Required: Software Development Environment

Preparation Tasks

Confirm that all computers are turned on and logged-in

1 to 3 minutes

Confirm that your projector is turned on and is projecting properly

1 to 4 minutes

Install Python 2.x (https://www.python.org/downloads) or navigate to Trinket (https://trinket.io/)

5 to 10 minutes

Pre-load Python Starter Files (or copy and paste in the code)

20 minutes

The Lesson

Warm-up Activity: Recognizing patterns in the coefficient and constant

20 minutes

Activity 1: Using Python to solve problems

20 minutes

Activity 2: Calculating slope

10 minutes

Activity 3: Designing an algorithm to find the slope of any line

20 minutes

Wrap-up Activity: Using Python to write the equation of a line

10 minutes

Warm-up Activity: Recognizing patterns in the coefficient and constant (20 minutes)

Activity Overview: In this activity, students will look for patterns between the change in y values and the slope of a line and the y value when x equals zero and the y-intercept of a line.They will use the CT concepts of pattern recognition, data representation, and decomposition to move between representing a line in chart form, equation form, and graphical form.

Activity:

Students begin this lesson by completing the chart below. Remind students that they can calculate the changes in x and y by subtracting the second from the first value. As students work, they should look out for patterns or relationships between 1) the change in y values and the slope of the line, and 2) the y value when x equals zero and the y-intercept of the line. This activity can be completed individually or in small groups.

Q1: Complete the chart below. Describe any patterns you notice in the numbers you recorded and (f) the slope and y-intercept. 

Line 1

Line 2

Line 3

(a) Graph of points on the line

(b) Table of points in terms of x and y

x

0

1

2

3

4

y

3

7

11

15

19

                      

 

x

0

1

2

4

y

7

9

11

15

x

0

1

2

3

4

y

-5

2

9

16

23

(c) Increase in x

1 - 0 = 1

(d) Increase in y

7 - 3 = 4

(e) Value of y when

        x = 0

3

(f) Slope (m) and y-intercept (b)

m = 4

b = 3

y = 4x + 3

m = 2

b = 7

y = 2x+7

m = 7

b = -5

y = 7x - 5

Notes to the Teacher:

In the first problem, students should have noticed that the value of y when x = 0, is always the y-intercept. In the second problem however, they are now not given this value of y. Thus in order to figure out the y-intercept, students will need to decompose the chart and count down to get to x = 0.

Teaching Tip:

  • If this activity is being completed in small groups, organize groups by experience level so students in each group will work at a similar pace.
  • Change the amount of information already calculated or provided in the chart in order to change the level of difficulty.

Assessment:

A1: Answers may vary but students should notice that the slope is equal to the increase in y, and the y-intercept is equal to the value of y when x = 0.

Line 1

Line 2

Line 3

(a) Graph of points on the line

(b) Table of points in terms of x and y

x

0

1

2

3

4

y

3

7

11

15

19

                      

 

x

0

1

2

4

y

7

9

11

15

x

0

1

2

3

4

y

-5

2

9

16

23

(c) Increase in x

1 - 0 = 1

1 - 0 = 1

1 - 0 = 1

(d) Increase in y

7 - 3 = 4

9 - 7 = 2

2 - -5 = 7

(e) Value of y when

        x = 0

3

7

-5

(f) Slope (m) and y-intercept (b)

m = 4

b = 3

y = 4x + 3

m = 2

b = 7

y = 2x+7

m = 7

b = -5

y = 7x - 5

Activity:

Have students work through the following activity.

Q2: Study the table below to answer the following question.

x

4

5

6

7

8

9

10

y

13

18

23

28

33

38

43

What piece of information is missing in order to determine the y-intercept of the line that passes through these set of points? 

Q3: To help you decompose this problem and find the y-intercept of the line that passes through the given set of points, we’ve extended the previous table. Look for relationships between the numbers to complete the chart below:

x

4

5

6

7

8

9

10

y

13

18

23

28

33

38

43

What is the slope and y-intercept of this line? 

Assessment:

A2: The value of y when x equals zero.

A3: slope = 5, y-intercept = -7

x

0

1

2

3

4

5

6

7

8

9

10

y

-7

-2

3

8

13

18

23

28

33

38

43


Activity 1: Using Python to solve problems (20 minutes)

Activity Overview: In this activity, students will use the same algorithm they applied in the previous exercise. Students will use the CT concepts of pattern recognition, data representation, algorithm design and automation to write a Python program to automate the tedious tasks of calculating points on a line.

Activity:

In the Warm-up activity, students had to change the values they subtracted each time they were given a new set of points. They can generalize this process by instead asking for the increase in y and then telling Python to subtract that increase, whatever it may be, from the current y value each time Python loops. So far we have only seen sets of points in which the change in x is 1, so students will tell Python to always subtract 1 from the current x value.

Have students work through the following activity.

An algorithm is a step-by-step process that explains how to solve a problem. Computers follow algorithms to help us do things like search the web, type essays, and play games.

Chart A

x

37

38

39

40

41

42

43

y

51

60

69

78

87

96

105

Chart B

x

54

55

56

57

58

59

60

y

75

79

83

87

91

95

99

Q1: What makes the numbers in these two tables more challenging to calculate their slope and y-intercept? 

Q2: Write an algorithm in words to explain how to decompose Chart A to find the y-intercept of the points (do NOT actually find the y-intercept).

Q3: Write an algorithm in words to explain how to decompose Chart B to find the y-intercept of the points (do NOT actually find the y-intercept). 

Notes to the Teacher:

Remind students that a while loop will continue to do whatever it’s told while a certain condition is met. In this case we want it to count down while x is greater than zero. When it reaches x = 0, the loop will end, and we can print out the corresponding y value.

Student Assessment:

A1: They are bigger and further away from zero.

A2: Answers may vary; students should realize they can count backwards from 37 to 0, while also counting down from 51, subtracting 9 from the y value each time that they subtract 1 from x.

A3: Answers may vary; students should realize they can count backwards from 54 to 0, while also counting down from 75, subtracting 4 from the y value each time that they subtract 1 from x.

Activity:

Ask students to complete the following questions.

Chart A

x

37

38

39

40

41

42

43

y

51

60

69

78

87

96

105

Chart B

x

54

55

56

57

58

59

60

y

75

79

83

87

91

95

99

Instead of manually determining the value of y when x = 0, you can develop an algorithm that Python can follow to do this for you.

Q4: In Chart A, what is subtracted from the first known x value (37) to get the previous x value?

Q5: What is subtracted from the first known y value (51) to get the previous y value?

Q6: Use these two numbers to fill in the blanks in Program 1 and then run your program to calculate the y-intercept for the first line.

Q7: Follow the same process for the next program to calculate the y-intercept of the line in Chart B. 

Program 1 with Chart A solution, followed by Chart B solution

first_x = int(input('1st x value: '))

first_y = int(input('1st y value: '))

while first_x > 0:

        first_x = first_x - 1

        first_y = first_y - 9

print 'y-intercept: ', first_y

first_x = int(input('1st x value: '))

first_y = int(input('1st y value: '))

while first_x > 0:

        first_x = first_x - 1

        first_y = first_y - 4

print 'y-intercept: ', first_y

Output:                                                        Output:

y-intercept: -282                                    y-intercept: -141                    

It would be nice if we did not have to change our program every time we had a different increase in y. Take a look at the code in Program 2.

Program 2

first_x = int(input('1st x value: '))

first_y = int(input('1st y value: '))

y_increase = int(input('Increase in y: '))

while first_x > 0:

        first_x = first_x - 1

        first_y = first_y - y_increase

print 'y-intercept: ', first_y

Notice that now there is a third input. Use this to variable to complete the program above, so that Python knows what value to subtract from y as it counts down.

Now, use Program 2 to identify the y-intercept of the following two sets of points:

x  

16

17

18

19

20

21

22

y   

100

103

106

109

112

115

118

x

45

46

47

48

49

50

51

y

50

57

64

71

78

85

92

Output:                                                       Output:

y-intercept = 52                                    y-intercept = -265

Assessment:

A4: 1

A5: 9

A6: See Program 1, Chart a solution

A7: See Program 1, Chart b solution


Activity 2: Calculating slope (10 minutes)

Activity Overview: In this activity, students will program Python to calculate slope. Students will use the CT concepts of data representation, data analysis, and patterns recognition to determine if a pattern holds true in new charts of data.

Activity:

Students programmed Python to calculate the y-intercept, and now need to program it to calculate the slope. Remind students, in Activity 1 the slope was always the same as the y-increase. However, in this exercise they will see that pattern only holds true when the increase in x equals one. For larger increases in x they will need to come up with a new algorithm.

Work through the following activity with students.

The table below contains two of the charts from the first activity as well as two new charts. Take a minute to think about how we used the values in the two previous charts to figure out the slope.

Previous charts

Slope (m) and y-intercept (b)

 x increase: 1, y increase: 4

 m = 4, b = 3

x increase: 1, y increase: 2

 m = 2, b = 7

New charts

x

6

8

10

12

14

16

18

y

20

26

32

38

44

50

56

x

15

19

23

27

31

35

39

y

20

28

34

42

50

68

74

Slope (m) and y-intercept (b)

 x increase: 2,  y increase: 6

 m = 3, b = 2

 x increase: 4  y increase: 8

 m = 2, b = -10

Q1: In the previous charts, the increase in y is also the slope (m). Is this true for the new charts?

In the next activity you will apply what you have learned to find the slope and y-intercept of the line that passes through a set of points in which the x values increase by more than 1.

Student Assessment:

A1: No


Activity 3: Designing an algorithm to find the slope of any line (20 minutes)

Activity Overview: In this activity, students will use the knowledge they’ve gained to complete a final program that calculates the slope and y-intercept, and uses these values to write equation of a line that passes through any linear set of points. Students will use the CT concepts of data representation, data analysis, and pattern recognition to decompose chart data representing lines to facilitate analysis and recognition of patterns and relationships between the increase in x, the increase in y, the slope, and the y-intercept. They will then use the CT concepts of algorithm design and automation to write a program to write the equation of a line that passes through any set of linear points.

Activity:

Have students complete the following activity.

Q1: The slope is equal to the increase in y, only when the increase in x is ONE. However, in the new charts introduced in the previous activity, x increases by more than one! Let's decompose the first chart so that it is easier to see the change in y for each unit change in x:

Q2: This time we need to find the slope AND the y-intercept, but we do not know how much y increases for each ONE unit increase in x. We also do not know the value of y when x = 0. Let’s decompose the first chart together in order to identify a pattern in the increase in y for every one unit increase in x. Complete the chart below to help you identify the slope (m) and y-intercept (b).

x

4

7

10

13

16

19

22

y

50

62

74

86

98

110

122

x

4

5        

 6  

7

 8  

  9 

10

y

50

54

58

62

66

70

74

Assessment:

A1: m = 3

A2: m = 4  b  = 34  (use Program 2 above to calculate the y-intercept)

Activity:

Have students complete the following activity.

Review the original charts to complete the statements. Do the same for the next two problems.

x

6

8

10

12

14

16

18

y

20

26

32

38

44

50

56

x

6

7

8

9

10

11

...

y

20

23

26

29

32

35

...

x increases by 2

y increases by 6

x increases by 1

y increases by 3 (slope)

x

4

7

10

13

16

19

22

y

50

62

74

86

98

110

122

x

4

5

6

7

8

9

10

...

y

50

54

58

62

66

70

74

...

x increases by 3

y increases by 12

x increases by 1

y increases by 4 (slope)

Look for patterns in the numbers to help you develop an algorithm for calculating the slope.

Q3: How can we use the x and y increases to calculate slope?

Assessment:

A3: Divide the y increase by the x increase.

Activity:

Have students complete the following tasks.

Use the method you noted for calculating slope in the Python code below.

x_increase = float(input('Enter the increase in x: '))

y_increase = float(input('Enter the increase in y:'))

slope = y_increase/x_increase

print 'slope: ', slope

Q4: Run the above code to calculate the slope of the line passing through the following set of points:

x

45

49

53

57

61

65

y

30

40

50

60

70

80

We can combine the ideas from the exercises above to complete a Python program that will print out the slope and y-intercept of a line.  When you run the program, you will see that these numbers are also used to write the equation of the line that passes through a given set of points. 

Refer to the “expanded” tables above to complete the code below:

first_x = float(input('Enter the first x value: '))

first_y = float(input('Enter the first y value: '))

x_increase = float(input('Enter the change in x: '))

y_increase = float(input('Enter the change in y: '))

slope = y_increase/x_increase

while first_x > 0:

         first_x = first_x - 1    

         firsty = first_y - slope

print 'Slope: ',slope

print 'Y-intercept: ',first_y

print 'Equation of the line: y =',slope,'x + ',first_y

Assessment:

A4: m = 2.5

Notes to the Teacher:

As students work through the two tables, have them stop and compare the values they get. By doing so, they should notice that if they divide the increase in y by the increase in x, they will arrive at the slope of the line.

In the following program students will use the knowledge they’ve gained to complete a final program that calculates the slope and y-intercept, and uses these values to write equation of a line that passes through any linear set of points. The two blanks in this code are trickier than in previous programs. They are based on the idea that for every one unit change in x, the change in y is equal to the slope of the line. Allow students time to work on the code below by themselves, and then discuss it as a class to ensure that everyone understands how it works.


Wrap-up Assessment: Using Python to write the equation of a line (10 minutes)

Activity Overview: In this activity, students will be assessed on their ability to write a python program to write the equation of a line given the line in chart or table format. They should have already written this program in the last activity. Now they are just using it for the assessment to test its efficacy. Students will use the CT concept of automation to use their program to write the equation of a line that passes through any set of linear points.

Activity:

Give the assessment for the students to complete.

Q1: Use your Python program to find the equations of the lines passing through each set of points below:

x

7

8

9

10

11

12

13

y

3

4.5

6

7.5

9

10.5

12

Q2:

x

 12 

15

18

21

24

27

30

y

19

25

31

37

42

48

54

Q3:

x

 53 

58

63

68

72

78

83

y

12

20

28

36

44

52

60

Assessment:

A1: Equation of the line: y = 1.5x - 7.5

A2: Equation of the line: y = 2x - 5

A3: Equation of the line: y = 1.6x - 72.8

Learning Objectives and Standards

Learning Objectives

Standards

LO1: Understand the connections between proportional relationships, lines, and linear equations.

Common Core

CCSS MATH.CONENT.8.EE: Work with radicals and integer exponents

Computer Science

CSTA L2.CT.14: Examine connections between elements of mathematics and computer science including binary numbers, logic, sets and functions.

Additional Information and Resources

Lesson Vocabulary

Term

Definition

For Additional Information

Slope

A number that describes both the direction and the steepness of the line.

http://en.wikipedia.org/wiki/Slope

Y-intercept

A point where the graph of a function or relation intersects with the y-axis of the coordinate system.

http://en.wikipedia.org/wiki/Y-intercept

Computational Thinking Concepts

Concept

Definition

Algorithm Design

Creating an ordered series of instructions for solving similar problems

Automation

Having computers or machines do repetitive tasks

Data Analysis

Making sense of data by finding patterns or developing insights

Data Representation

Depicting and organizing data in appropriate graphs, charts, words or images

Decomposition

Breaking down data, processes or problems into smaller, manageable parts

Pattern Recognition

Observing patterns and regularities in data

Administrative details

Contact info

For more info about Exploring Computational Thinking (ECT), visit the ECT website (g.co/exploringCT)

Credits

Developed by the Exploring Computational Thinking team at Google and reviewed by K-12 educators from around the world.

Last updated on

07/02/2015

Copyright info

Except as otherwise noted, the content of this document is licensed under the Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache 2.0 License.


 ECT: Slope and Y-Intercept                                                                                              of