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

Big Idea - Abstraction
  • EU 2.2 - Multiple levels of abstraction are used to write programs or create other computational artifacts.
    • LO 2.2.3 - Identify multiple levels of abstractions that are used when writing programs. [P3]
      • EK 2.2.3B - High-level programming languages provide more abstractions for the programmer and make it easier for people to read and write a program.
      • EK 2.2.3C - Code in a programming language is often translated into code in another (lower-level) language to be executed on a computer.
Big Idea - Programming
  • EU 5.1 - Programs can be developed for creative expression, to satisfy personal curiosity, to create new knowledge, or to solve problems (to help people, organizations, or society).
    • LO 5.1.3 - Collaborate to develop a program. [P6]
  • EU 5.3 - Programming is facilitated by appropriate abstractions.
    • LO 5.3.1 - Use abstraction to manage complexity in programs. [P3]
      • EK 5.3.1I - Strings and string operations, including concatenation and some form of substring, are common in many programs.
      • EK 5.3.1J - Integers and floating-point numbers are used in programs without requiring understanding of how they are implemented.
  • EU 5.5 - Programming uses mathematical and logical concepts.
    • LO 5.5.1 - Employ appropriate mathematical and logical concepts in programming. [P1]
      • EK 5.5.1A - Numbers and numerical concepts are fundamental to programming.
      • EK 5.5.1B - Integers may be constrained in the maximum and minimum values that can be represented in a program because of storage limitations.
      • EK 5.5.1C - Real numbers are approximated by floating-point representations that do not necessarily have infinite precision.
      • EK 5.5.1D - Mathematical expressions using arithmetic operators are part of most programming languages.
      • EK 5.5.1E - Logical concepts and Boolean algebra are fundamental to programming.
      • EK 5.5.1F - Compound expressions using and, or, and not are part of most programming languages.

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.
  • Python is a high level language that provides abstractions that make it easy to create powerful programs.
  • High level languages are translated by the computer into a lower level language that the computer can process.

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 (5 min)

  • 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)

Point out that Python is a high level programming language. It provides many tools that make it easy to build complex programs with little effort. In order for the computer to process the code, it must translate(compile) the Python statements into a lower level language that the particular computer can understand and process. A variety of different variable types is one of the abtractions that are available in a high level programming language, and the language must define how the data is both stored and manipulated for each kind of data. You do not need to understand HOW the implementation works in order to use variables in your program.

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)

Students will complete the Exploration Questions 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:

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.