Getting Started (5 min)

Write a reflection on the homework from last class to write code to introduce yourself. The program should:
 Display your name.
 Greet and ask for three interests.
 Display the three interests
 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 Note: Ideally, 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. Among these tools are the ability to store and retrieve values and evaluate (find the single value of) expressions. Python can evaluate  find the specific value of  variables, variables with operators like plus and times, and of functions.
Numeric values can be constants like an integer, retreived form numeric variables or calculated based on expressions that combine values or variables witharithemtic operators.
In order for the computer to execute 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!
 The Exam Reference Sheet uses these same symbols for arithmetic operators.
 Integers (ints):
 Values: ... 3, 2, 1,0,1,2,3,4
 Integer literals have no commas (1, 2, 10, 1034453)
 In many programming languages, integers are represented by a fixed number of bits, which limits the range of integer values and mathematical operations on those values. This limitation can result in overflow or other errors.
 The Exam Reference Sheet defines integers that are limited only by the size of the computer's memory.
 Operations: +, , * (multiply), /, ** (to the power of), % (MOD operator)
 The Exam Reference Sheet uses a MOD b, which evaluates to the remainder when a is divided by b, instead of a % b as in Python
 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)
 In programming languages, the fixed number of bits used to represent real numbers limits the range and mathematical operations on these values; this limitation can result in roundoff and other errors. Some real numbers are represented as approximations in computer storage.
 Operations: +, , * (multiply), /, ** (to the power of)
 Exponential notation is useful!
 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
 Range of values (int and float):
 In many programming languages, integers and floats are represented by a fixed number of bits, which limits the range of values and mathematical operations on those values.
 In some languages such as Python, the range of values is only limited by the size of the computer memory and not the number of bits used to represent the values
 In programming languages where the range of values is limited by a fixed number of bits, overflow and roundoff errors can occur.
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)
 Group students (see differentiation for grouping options).
 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 are to complete the Lesson 2.9 Order of Operations in Runestone (https://runestone.academy/runestone/books/published/thinkcspy/SimplePythonData/OrderofOperations.html)
Students will complete the Exploration Questions worksheet which is found in the Lesson Resources folder and complete one of the two exercises below.
 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"
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 highfive. They may not highfive 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:
 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.
 Create small, individual sets of cards, and have them glue the cards in to their journals by type.
 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.
 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.teachnology.com/web_tools/materials/bingo/5/