Lesson Summary

Pre-lesson Preparation

Create a table of values of all types and print a copy of them on the cardstock for each group. Cut the papers up into individual cards, so each value is on its own card. Place each group's cards in a plastic bag.

Summary

Students are introduced to basic programming vocabulary, including integers, floats, strings, values, and expressions.  They will work through a set of guided notes and slides, and then, be released to explore Python through an independent (or paired) exercise. 

Outcomes

  • Students will learn that values are fundamental things that the program manipulates.
  • Students will program four different types of values: floats, ints, strings, and booleans (briefly).
  • Students will understand that expressions are evaluated by Python and result in a value.
  • Students will understand that statements are executed by Python and may not result in a value.

Overview

  1. Getting Started (5 min)
  2. Introduction of Content (10 min)
  3. Guided Activity: Type Sort (15 min)
  4. Independent Activity (15 min)
  5. Wrap Up (5 min)

Learning Objectives

CSP Objectives

Math Common Core Practice:

  • MP1: Make sense of problems and persevere in solving them.
  • MP3: Construct viable arguments and critique the reasoning of others.
  • MP6: Attend to precision.
  • MP7: Look for and make use of structure.
  • MP8: Look for and express regularity in repeated reasoning.

Common Core ELA:

  • RST 12.4 - Determine the meaning of symbols, key terms, and other domain-specific words and phrases
  • RST 12.8 - Evaluate the hypotheses, data, analysis, and conclusions in a science or technical text
  • WHST 12.6 - Use technology, including the Internet, to produce, publish, and update writing products

NGSS Practices:

  • 2. Developing and using models
  • 5. Using mathematics and computational thinking

Key Concepts

  • Values are fundamental things that the program manipulates.
  • So far, we have seen four different types of values: floats, ints, strings, and booleans (briefly).
  • Expressions are evaluated by Python and result in a value.
  • Statements are executed by Python and may not result in a value.

Essential Questions

  • How are vastly different kinds of data, physical phenomena, and mathematical concepts represented on a computer?
  • How do people develop and test computer programs?
  • Which mathematical and logical concepts are fundamental to computer programming?
  • What is the difference between an expression and a statement?
  • What are the different data types?

Teacher Resources

Student computer usage for this lesson is: required

In the Lesson Resources folder:

  • "Values and Types" slides
  • "Exploration Question" document

Team Shake App 

Runestone: Values and Expressions

Lesson Plan

Getting Started (5min)

  • Write a reflection on the homework from last class to write code to introduce yourself. The program should:

    1. Display your name.
    2. Greet and ask for three interests.
    3. Display the three interests
    4. Give a reply like "That's interesting!"

    Did you run into any errors?

    Do you feel that you can easily write this kind of code?

    Share results with an elbow partner.

Teacher NoteIdeally, students are paired with people they don't work with as frequently, in order to promote classroom culture.

Introduction of Content (10 min)

Refer to the PowerPoint called Values and Types in the Lesson Resources folder. 

  • Value:
    • Everything on a computer reduces to numbers
      • Letters are represented by numbers (ASCII codes)
      • Pixel colors are represented using three numbers (red, green, blue)
    • Python tells these numbers apart by the use of types
  • Type:
    • A set of values and the operations performed on them
      • Examples of operations: +, -, /, *
      • The meaning of these depends on the type!
  • Integers (ints):
    • Values: ... -3, -2, -1,0,1,2,3,4
      • Integer literals have no commas (1, 2, 10, 1034453)
    • Operations: +, -, * (multiply), /, ** (to the power of)
  • Floating point (float):
    • Values: (approximations of) real numbers
      • In Python, a number with a '.' is a float (ie. 2.0)
      • Without a decimal, a number is an int (ie. 2)
    • Operations: +, -, * (multiply), /, ** (to the power of)
    • Exponential notation is useful!

Check for Understanding: Have students write an integer on their paper (check with their elbow partner that it is a number). Ask students to turn that integer into a float with the same numerical value.  Talk about going the opposite direction (float to int).

(Example answers:  int: 3   float: 3.0 or 3.00 or ...)

  • String (str):
    • Values: Any sequence of characters within double or single quotes
    • Operations: + (referred to as catenation or concatenation)
    • Concatenation can only apply to strings
      • "hello" + "world" = "helloworld" 
      • "hello" + " world" = "hello world"
      • "hello" + 2 produces an error
  • Boolean (bool) :
    • Values: True, False
      • Boolean literals are just True and False (they must be capitalized!)
    • Operations: not, and, or
      • not b: True if b is False and False if b is True
      • b and c: True if both b and c are True; False otherwise
      • b or c: True if b is True or c is True; False otherwise
    • Check for Understanding: Hold up two objects for the students to see, then ask the following questions:
      • I am holding object A and object B. True or False?
      • Drop one of the objects. I am holding object A and object B. True or False?
      • I am holding object A or object B. True or False?
    • Often comes from comparing int or float values
      • Order comparison: i< j     i<=j    i>=j    i>j
      • Equality, inequality: i == j     i!= j   ('=' means something else!)

Guided Activity: Type Sort (15 min)

  1. Group students (see differentiation for grouping options).
  2. Ask teams of students to group the values by types.

Teacher Note: See Differentiation for two variations of this activity.

Individual Activity (15 min)

Studens will complete the Exploration Worksheet which is found in the Lesson Resources folder. 

  • Version 1:
    • Hand out exploration worksheet and allow students to work individually on their computer in PyCharm IDE or terminal/command. 
    • Make sure students are filling in their expected value before determining the calculated value.  They need only fill in the "reason for calculated value" if their two values do not match originally.
  • Version 2:
    • If a student needs a little more practice before moving on, send them to the Runestone to complete the Variables and Expressions activity before releasing them to the exploration:
      http://interactivepython.org/runestone/static/thinkcspy/SimplePythonData/simpledata.html#values-and-data-types

Wrap Up (5 min)

  • Exit ticket: Give the value of the Python expression. Also give the name of the operator used.
2 + 5
5 * 2
5 ** 2
5 / 2
5 % 2
5 + 2 * 4
5 * 2 - 3
  • Which of the following Python expressions give an error in Python?
"pay attention to details'
' " what's for lunch?", my partner asked'
"What's for lunch?", my partner asked"

Options for Differentiated Instruction

Ideas for grouping students:

  • Team Shake App A simple app that allows you to put in your students, decide the number of "teams", and randomly groups students. It will allow you to balance teams based on skill or gender, and will allow you to share teams via facebook or email.
  • Require students to go find other people in the room and give them a high-five. They may not high-five the person next to them. 
  • Group by birthday month (make adjustments to the groups as needed)
  • Number off
  • Ask students to count up the letters in their first name and determine if they have an odd number of letters or an even number of letters.  Find three or four others who also have an even or odd number of letters in their name and form a group. 
    • Variation if you have talked about other number systems:  Find the number of letters mod the number of groups you need.

Group Activity Variations:

  1. Give the students a large piece of colored paper and a glue stick, and allow them to glue the types together for later use in the classroom.
  2. Create small, individual sets of cards, and have them glue the cards in to their journals by type.
  3. Create multiple sets of values. Hand all groups the first set of values and allow them to organize the values by type.  For the remaining sets, have groups compete against one another to see who can sort the values the fastest.
  4. Print out Bingo cards of values ahead of time and call for: an integer less than 10 and greater than 5, a String with 3 letters, etc. http://www.teach-nology.com/web_tools/materials/bingo/5/ 

Evidence of Learning

Formative Assessment

Checks for understanding are incorporated throughout the lesson.


Summative Assessment

Exit ticket questions are incorporated into lesson.