Lesson Summary

Summary

Students will be introduced to programming for the first time. They will learn about computer science, computing for good, some of the potential outcomes of programming, and the definition of abstraction.

Outcomes

  • Students will learn various creative and helpful purposes for programming.
  • Students will learn about abstraction.
  • Students will create Python code in Runestone.

Overview

  1. Getting Started (5 min)
  2. Guided Activities (40 min)
    1. Activity 1: Computing for Good [15 min]
    2. Activity 2: Coding with Python in Runestone [25 min]
  3. Optional homework: Read and write a tweet about one of the Seven things you should know if you’re starting out programming [10 min]

Learning Objectives

CSP Objectives

Big Idea - Creativity
  • EU 1.1 - Creative development can be an essential process for creating computational artifacts.
    • LO 1.1.1 - Apply a creative development process when creating computational artifacts. [P2]
      • EK 1.1.1B - Creating computational artifacts employs an iterative and often exploratory process to translate ideas into tangible form.
  • EU 1.2 - Computing enables people to use creative development processes to create computational artifacts for creative expression or to solve a problem.
    • LO 1.2.1 - Create a computational artifact for creative expression. [P2]
      • EK 1.2.1B - Creating computational artifacts requires understanding of and use of software tools and services.
      • EK 1.2.1C - Computing tools and techniques are used to create computational artifacts and can include, but are not limited to, programming integrated development environments (IDEs), spreadsheets, three-dimensional (3-D) printers, or text editors.
      • EK 1.2.1D - A creatively developed computational artifact can be created by using nontraditional, nonprescribed computing techniques.
      • EK 1.2.1E - Creative expressions in a computational artifact can reflect personal expressions of ideas or interests.
    • LO 1.2.2 - Create a computational artifact using computing tools and techniques to solve a problem. [P2]
      • EK 1.2.2B - A creative development process for creating computational artifacts can be used to solve problems when traditional or prescribed computing techniques are not effective.
    • LO 1.2.3 - Create a new computational artifact by combining or modifying existing artifacts. [P2]
      • EK 1.2.3C - Combining or modifying existing artifacts can show personal expression of ideas.
Big Idea - Data
  • EU 3.1 - People use computer programs to process information to gain insight and knowledge.
    • LO 3.1.2 - Collaborate when processing information to gain insight and knowledge. [P6]
      • EK 3.1.2A - Collaboration is an important part of solving datadriven problems.
      • EK 3.1.2B - Collaboration facilitates solving computational problems by applying multiple perspectives, experiences, and skill sets.
      • EK 3.1.2C - Communication between participants working on data-driven problems gives rise to enhanced insights and knowledge.
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.1 - Develop a program for creative expression, to satisfy personal curiosity, or to create new knowledge. [P2]
      • EK 5.1.1A - Programs are developed and used in a variety of ways by a wide range of people depending on the goals of the programmer.
      • EK 5.1.1B - Programs developed for creative expression, to satisfy personal curiosity, or to create new knowledge may have visual, audible, or tactile inputs and outputs.
  • EU 5.2 - People write programs to execute algorithms.
    • LO 5.2.1 - Explain how programs implement algorithms. [P3]
      • EK 5.2.1A - Algorithms are implemented using program instructions that are processed during program execution.
      • EK 5.2.1B - Program instructions are executed sequentially.
      • EK 5.2.1F - Processes use memory, a central processing unit (CPU), and input and output.
  • EU 5.3 - Programming is facilitated by appropriate abstractions.
    • LO 5.3.1 - Use abstraction to manage complexity in programs. [P3]
      • EK 5.3.1H - Data abstraction provides a means of separating behavior from implementation.
Big Idea - Impact
  • EU 7.1 - Computing enhances communication, interaction, and cognition.
    • LO 7.1.1 - Explain how computing innovations affect communication, interaction, and cognition. [P4]
      • EK 7.1.1E - Widespread access to information facilitates the identification of problems, development of solutions, and dissemination of results.
      • EK 7.1.1M - The Internet and the Web have enhanced methods of and opportunities for communication and collaboration.
      • EK 7.1.1N - The Internet and the Web have changed many areas, including e-commerce, health care, access to information and entertainment, and online learning.
      • EK 7.1.1O - The Internet and the Web have impacted productivity, positively and negatively, in many areas.
  • EU 7.4 - Computing innovations influence and are influenced by the economic, social, and cultural contexts in which they are designed and used.
    • LO 7.4.1 - Explain the connections between computing and real-world contexts, including economic, social, and cultural contexts. [P1]
      • EK 7.4.1A - The innovation and impact of social media and online access varies in different countries and in different socioeconomic groups.
      • EK 7.4.1B - Mobile, wireless, and networked computing have an impact on innovation throughout the world.
      • EK 7.4.1C - The global distribution of computing resources raises issues of equity, access, and power.
      • EK 7.4.1D - Groups and individuals are affected by the "digital divide" - differing access to computing and the Internet based on socioeconomic or geographic characteristics.
      • EK 7.4.1E - Networks and infrastructure are supported by both commercial and governmental initiatives.

Common Core ELA:

  • RST 12.4 - Determine the meaning of symbols, key terms, and other domain-specific words and phrases
  • RST 12.10 - Read and comprehend science/technical texts
  • WHST 12.2 - Write informative/explanatory texts, including the narration of historical events, scientific procedures/experiments, or technical processes
  • WHST 12.9 - Draw evidence from informational texts to support analysis, reflection, and research

Key Concepts

Students must understand that stereotypes of computer programmers are not accurate, and that 'coding' is something everyone can learn to do. Computing can be a creative expression and used for good.

Possible misunderstandings: The term NGO is used in the article Programming for Good: The Story of Code for India, without explicitly defining it as Non-Governmental Organization. 

Abstraction is a tricky idea. Python allows us to describe what we want to do such as "print" and "input" because it provides the details that explain to the computer how to accomplish the task of taking many keypresses followed by a press of the Enter key to allow the computer to store the information we entered, and also knows how to take information stored in the computer's memory and cause it to appear as a series of recognizable dots on the screen using print. Computer programs use input, output, processing and memory.


Essential Questions

  • How can computing and the use of computational tools foster creative expression?
  • How does abstraction help us in writing programs, creating computational artifacts and solving problems?
  • How can computation be employed to help people process data and information to gain insight and knowledge?
  • What opportunities do large data sets provide for solving problems and creating knowledge?
  • How are programs developed to help people, organizations or society solve problems?
  • How are programs used for creative expression, to satisfy personal curiosity or to create new knowledge?
  • How does abstraction make the development of computer programs possible?
  • How does computing enhance human communication, interaction, and cognition?
  • How does computing enable innovation?
  • How do economic, social, and cultural contexts influence innovation and the use of computing?

Teacher Resources

Student computer usage for this lesson is: required

TEACHERS need to have the class and user accounts set up in Runestone to track student progress.

For the Students:

Note: If computer is not being used, students will need their own copies of the articles

Lesson Plan

Getting Started (5 min)

[use the Presentation on Programming Python in Runestone]

Journal Entry: What are some ways that writing programs is a creative endeavor? [ slide 2]

Share answers with your elbow partner. Then share answers with class

Note to the teacher: This lesson comes immediately after the practice Explore performance task. To provide more time for sharing and discussion, you may want to assign the reading and questions from Activity 1 as homework in addition or instead of the optional homework.

Guided Activities (40 min)

Activity 1: Computing for Good [15 min]

Open Discussion: What are some ways you know that computing has been used for “good?” [ slide 3 ]

Go to Programming for Good: The Story of Code for India

http://www.attendly.com/programming-for-good-the-story-of-code-for-india/

Read articles or selected text in pairs, with alternating pairs each reading one article. Pairs of pairs get together to share what they read and what they got out of the article.

In pairs, answer the following questions:

  1. How did the impact of Hurricane Sandy in 2012 begin the concept of Code for India?
  2. What is the reason for the Adopt-a-School app, and what is the result of its use?
  3. What is the reason for the Spotter app?
  4. What is the reason for the Bravehearts app, and what is its significance for public safety? Where else would this app be useful?
  5. If you were able to design an app “for good,” what problem would you try to solve?

Check for Understanding: Teams should share their answers to their instructor.

Activity 2: Coding with Python in Runestone [25 min]

Have students schetch the computer hardware architecture diagram in Python for Everybody Chapter See https://books.trinket.io/pfe/01-intro.html#computer-hardware-architecture.

Explain that computer processes guide the flow of information that is input, processed, stored or output. The processor (CPU) uses short term memory for doing calculations and temporary storage and long term memory if needed. Have students sketch the computer components diagram above.  Explain to students that they will learn to program to develop software using each of these components.

This could be review from a previous computer class.  If it is new to students assign one or both of the following.

Watch the video on how programs use input, processing, memory and output to run programs. https://www.youtube.com/watch?v=BSTrWhAGta8

Read Computer Hardware architecture by Dr. Severance.

https://books.trinket.io/pfe/01-intro.html#computer-hardware-architecture

 .

BE SURE YOU HAVE SET UP STUDENT ACCOUNTS

  1. [Use the Presentation on Programming Python in Runestone slides 4].  Open Runestone as was done in Unit 1 Lesson 6. Students use their accounts to access the eTextbook
  2. Read The Way of the Program and answer questions on the student handout.
  3. Go to the next section: Algorithms and check to see that all student answers are being correctly recorded in Runestone. Display answer results on the teacher screen. Have students continue to fill in answers on student handout. [ slide 5]
  4. Have students independently complete the next 3 sections (or finish them for homework) and fill in the student handout.
  5. Skip ahead to A Typical First program [ slides 7-13]
    1. Demonstrate how to run the program, change the code, add an input line, and display the value input in the print statement.
    2. Explain the idea of syntax, and the result of various mistakes.
  6. Discuss abstracting in coding. [ slide 14 ]

Homework: Seven things you should know if you’re starting out programming

Have students go to the article Seven things you should know if you’re starting out programming at

http://www.theguardian.com/info/developer-blog/2011/oct/07/programming-developer-journalist

Before dividing the students into groups for the next activity, it is important to address the paragraph at the beginning of the reading, which mentions the "coder stereotype" and includes a parenthetical note that the author believes this stereotype to be (largely) accurate.  Explain that because of the breadth of application areas of computing in today’s world, this stereotype is not an accurate view of the diverse field of computing – there are a wide variety of people in computing and a wide variety of applications of computing education. See videos at http://mcwic.github.io/htmlblocks/computerscientistlibrary.html#top

In pairs or groups of three, assign each group to read and summarize one of the seven programming principles in the article.

  1. Logic (not "math")
  2. Catch a shooting star (variables)
  3. Dictionary (data types)
  4. Russian Dolls (things within things, instances)
  5. Sausage (processes)
  6. The dog, the cat, and the fish (causation, event change)
  7. Pizza (abstraction) include why abstraction is "like making pizza," and what other kinds of activities might fall into that category.

Check for Understanding: Each person should write a 140 character tweet on their topic, next class the group should share their findings with the class.





Options for Differentiated Instruction

Oral reading strategies such as "popcorn reading" where students take turns reading a paragraph and then pass the reading off to another student in the class, or other reading strategies such as students reading together quietly in pairs, can be used for longer texts. 

Longer readings can be broken up by sections or paragraphs to speed the lesson up or keep students engaged.

Activity 1 could be assigned as homework from the day before as a step into this lesson to allow more time in class for the other readings:

Additional activity: Ask students to read the Preface (pages iii-iv) and Chapter 1 introduction and section 1.1 (pages 1-2) of Python for Everybody  and answer these questions:

  1. Why does the author think that Python is a better teaching language for beginning programmers than Java?
  2. Why does the author consider programming to be a creative activity?  
  3. What things are computers better at doing than people?
  4. What things are people better at doing than computers?
  5. What are some motivations for writing computer programs? List some responses not included in the selected reading.
  6. What do you think of the author's writing style?  Name some positive and negative aspects of the presentation in the text.

Evidence of Learning

Formative Assessment

Students will use several different strategies for reading and writing responses based on their readings.

Classroom discussions and student responses (written and oral) will allow instructors to check for understanding.

 


Summative Assessment

Summative assessment will be included in Part 2 on the use of the PyCharm IDE.

Student handout filled in

Tweet from optional homework assignment

Progress recorded in Runestone for the General Introduction 

Lesson Summary

Summary

PyCharm, an IDE for Python, will be introduced. Keywords, file, and variable naming conventions will be addressed.

Outcomes

  • Students will find and launch PyCharm.
  • Students will configure PyCharm's appearance.
  • Students will create a Python project in PyCharm.
  • Students will name and save projects according to the requirements of their instructor.
  • Students will create a Python file (.py file).
  • Students will add line numbers to the file.
  • Students will add comments to the file.
  • Students will write, debug, and run a simple Python program.

Overview

  1. Getting Started (10 min)
  2. Guided Activity (20 min)
    1. Introduction to PyCharm
  3. Summative Assessment (20 min)
    1. Programming Exercise
  4. Homework Assignment

Learning Objectives

CSP Objectives

Big Idea - Creativity
  • EU 1.2 - Computing enables people to use creative development processes to create computational artifacts for creative expression or to solve a problem.
    • LO 1.2.1 - Create a computational artifact for creative expression. [P2]
      • EK 1.2.1A - A computational artifact is something created by a human using a computer and can be, but is not limited to, a program, an image, an audio, a video, a presentation, or a Web page file.
      • EK 1.2.1B - Creating computational artifacts requires understanding of and use of software tools and services.
      • EK 1.2.1C - Computing tools and techniques are used to create computational artifacts and can include, but are not limited to, programming integrated development environments (IDEs), spreadsheets, three-dimensional (3-D) printers, or text editors.
    • LO 1.2.5 - Analyze the correctness, usability, functionality, and suitability of computational artifacts. [P4]
      • EK 1.2.5A - The context in which an artifact is used determines the correctness, usability, functionality, and suitability of the artifact.
      • EK 1.2.5B - A computational artifact may have weaknesses, mistakes, or errors depending on the type of artifact.
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.2 - Develop a correct program to solve problems. [P2]
      • EK 5.1.2D - Program documentation helps programmers develop and maintain correct programs to efficiently solve problems.
      • EK 5.1.2E - Documentation about program components, such as code segments and procedures, helps in developing and maintaining programs.
      • EK 5.1.2F - Documentation helps in developing and maintaining programs when working individually or in collaborative programming environments.
      • EK 5.1.2J - A programmer designs, implements, tests, debugs, and maintains programs when solving problems.
  • EU 5.4 - Programs are developed, maintained, and used by people for different purposes.
    • LO 5.4.1 - Evaluate the correctness of a program. [P4]
      • EK 5.4.1C - Meaningful names for variables and procedures help people better understand programs.
      • EK 5.4.1E - Locating and correcting errors in a program is called debugging the program.
      • EK 5.4.1F - Knowledge of what a program is supposed to do is required in order to find most program errors.

Math Common Core Practice:

  • MP1: Make sense of problems and persevere in solving them.

Common Core ELA:

  • RST 12.3 - Precisely follow a complex multistep procedure
  • RST 12.4 - Determine the meaning of symbols, key terms, and other domain-specific words and phrases
  • WHST 12.2 - Write informative/explanatory texts, including the narration of historical events, scientific procedures/experiments, or technical processes
  • WHST 12.6 - Use technology, including the Internet, to produce, publish, and update writing products

Key Concepts

Students will learn what an IDE (Integrated Development Environment) is and why it is good to use one when programming. 

Students will be able to find, configure and use the PyCharm IDE to write, save, run, debug and retrieve their Python modules according to the requirements of their instructor. 

 


Essential Questions

  • How can computing and the use of computational tools foster creative expression?
  • How are vastly different kinds of data, physical phenomena, and mathematical concepts represented on a computer?
  • How do computer programs implement algorithms?
  • How do people develop and test computer programs?

Teacher Resources

Student computer usage for this lesson is: required

For the Students

Lesson Plan

Getting Started (10 min)

  • Journal: What environments have you already used to write Python programs?
  • Share answers in class.
  • After students have shared their answers, introduce the topic of Integrated Development Environments (IDEs). Explain that an IDE provides a way to manage files, write code, get help with code syntax and usage, and the ability to test, run, and debug programs in an environment they are able to configure to their own liking.
  • As defined by Wikipedia:  “An integrated development environment (IDE) or interactive development environment is a software application that provides comprehensive facilities to computer programmers for software development. An IDE normally consists of a source code editor, automation tools, and a debugger. Most modern IDEs offer intelligent code completion features.” (From: http://en.wikipedia.org/wiki/Integrated_development_environment)
  • Have students go to Python Central at http://www.pythoncentral.io/the-best-python-ides-you-can-use-for-development/ for a list of the top IDEs for Python. PyCharm is listed as one of the best. Explain to students that they will be learning to use the PyCharm IDE.
  • Share tweets from the homework about the 7 aspects of programming quickly standing up in place and sharing.
      1. Catch a shooting star (variables)
      2. Dictionary (data types)
      3. Russian Dolls (things within things, instances)
      4. Sausage (processes)
      5. The dog, the cat, and the fish (causation, event change)
      6. Pizza (abstraction) include why abstraction is "like making pizza," and what other kinds of activities might fall into that category.

        If they did not assign the homework, review Seven things you should know if you’re starting out programming 

         Have students go to the article Seven things you should know if you’re starting out programming at 

        http://www.theguardian.com/info/developer-blog/2011/oct/07/programming-developer-journalist

Activity (20 min)

Introduction to PyCharm

  • Find and launch PyCharm. If there is not a shortcut on your desktop, go to Programs >> JetBrains >> JetBrains PyCharm Community Edition 3.4.1.
  • The first screen will provide options for Create New Project, Open Directory, Check out from Version Control, Configure, and Docs and How-Tos.
  • Select Configure >> Settings >> Appearance. Explore Screens under UI Options. IntelliJ is the default appearance
    • Darcula and Windows are some other options.
    • Students should explore other options available.
    • Students should play with the appearance and select a new one (with your approval) if they have a preference.
  • Click the arrow to go back to the Quick Start menu.
  • Click Create New Project.
  • Give the project a name.
    • Click the ellipses (the … at the end of the location field) to navigate to the location you need to save your work.

Teacher note: This may be a good time to have students configure the default Working Directory as shown in the Python and PyCharm Installation and Configuration Guide file in the lesson resources folder.

  • When you click “OK,” your project will be created.
  • Click File >> New >> Python File to create your .py file. Name your first .py file rate_time.
    • The code for this module will be copied from the ‘Non-Programmer's Tutorial for Python 3/Who Goes There?’ tutorial shortly.
  • Click OK to create the file.
    • The user name of the author of the file will appear at the top of the code window with the default comment method.
  • Take students through some configuration modifications, such as adding line numbers, showing the console, and changing the default for comment style, all covered in the Installation and Configuration Guide.
    • If you are projecting your screen, you can use Presentation Mode to make viewing easier for students.
  • Allow students some time to explore the environment.
  • Visit Non-Programmer's Tutorial for Python 3/Who Goes There?
  • Prior to copying the code for rate_time.py and area.py, take students through the sections in the Non-Programmer's Tutorial for Python 3/Who Goes There? on Input and Variables.
  • Explain and model variable types and their behaviors, and concatenation.
    • For ease of use, consider using the comma at this time to avoid confusion about concatenation.
  • Create, save, run and debug programs rate_time.py and area.py.
  • To run a program for the first time, go to Run and select the file you want to run.
    • After that, the Run command will appear in the upper right corner of the PyCharm IDE.
  • As you add new modules to the project you will need to go to Run and select the new file.
    • After that, the file names will appear in a drop-down menu next to the green Run arrow.
  • If it has not already been configured, go to Tools >> Run Python Console to show the console at the bottom of the PyCharm environment. Students can use this to test their code as they have in other environments.
  • In the PyCharm console, test code from An Informal Introduction to Python 3.1 Using Python as a Calculator. (https://docs.python.org/3.4/tutorial/introduction.html#using-python-as-a-calculator).

Summative Assessment (20 min)

Students are to:

  • Create a new Python module (.py) called name.py.
  • Comment in their name, date, and name of project as directed by their instructor at the top of their code window.
  • Assign their full name to an appropriately named variable.
  • Assign their age to an appropriately named variable.
  • Output their name and age as a sentence, with variables and literal values concatenated correctly.
  • Debug any errors and run their program with the correct output and without error.

Sample code (will throw an error) 

# author = 'iam tester'
# date July 4, 2024
# name.py
name = 'Ima Tester'
age = 15
print (name + " is " + age + " years old.")

The above code will throw an error, because age is an integer and needs to be expressed as a string OR concatenated using a comma (,).

 name = 'Ima Tester'
age = 15
print (name,"is",age,"years old.")

Important notes about naming your files and variables:

  • Our Python coding examples will follow the PEP 8 Style Guide. (http://legacy.python.org/dev/peps/pep-0008/)
    • Teachers are not required to use this standard but should establish their classroom conventions for students to follow.
  • Modules written in Python, .py file names, should be in all lower case as is done with the sample files in the Python for Everybody textbook. (https://www.py4e.com/code3/)
  • Variable names should begin with a lowercase letter with multiple words separated by an underscore.
    • Teachers may choose to use camelCase or another naming system and should be specific and consistent with students regarding these requirements.
  • Python file names and variable names must not begin with a number, and cannot be the same as Python keywords: 
 and       del       from      not       while
as        elif      global    or        with
assert    else      if        pass      yield
break     except    import    print
class     exec      in        raise
continue  finally   is        return 
def       for       lambda    try

(from http://www.pythonforbeginners.com/basics/keywords-in-python)

  • For more information concerning variable names and keywords to Python, go to

Homework Assignment

  1. Use two sources to find definitions of "algorithm", cite the sources
  2. Write down the steps involved in a daily task – creating a peanut butter and jelly sandwich; getting to school; brushing teeth; completing homework; etc…) 

Options for Differentiated Instruction

 Students can work in pairs, side by side, to help each other through each step of the process.

 


Evidence of Learning

Formative Assessment

Checks for understanding throughout the entire process of learning to use the PyCharm IDE by using active participation in trying each step of the process and having students help their elbow partner when difficulties arise.


Summative Assessment

Assessment tasks:

  • Create a new Python program file.
  • Add a comment containing their name, date, and name of project as directed by their instructor at the top of their code window.
  • Assign their name to an appropriately named variable.
  • Assign their age to an appropriately named variable.
  • Output their name and age as a sentence with variables and literal values concatenated correctly.
  • Debug any errors and run their program with the correct output and without error.

Lesson Summary

Summary

This is the first day of a two-session lesson sequence with topics covered by mini-lectures, explorations, and practice exercises.

Outcomes

  • Students will be able to answer the question, "What is an algorithm?"
  • Students will explore algorithms described in English
  • Students will understand Magic Square construction and parallel algorithms

Overview

  1. Getting Started (5 min)
  2. Activities (40 min)
  3. 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.1 - Develop an abstraction when writing a program or creating other computational artifacts. [P2]
      • EK 2.2.1A - The process of developing an abstraction involves removing detail and generalizing functionality.
      • EK 2.2.1B - An abstraction extracts common features from specific examples in order to generalize concepts.
      • EK 2.2.1C - An abstraction generalizes functionality with input parameters that allow software reuse.
Big Idea - Algorithms
  • EU 4.1 - Algorithms are precise sequences of instructions for processes that can be executed by a computer and are implemented using programming languages.
    • LO 4.1.1 - Develop an algorithm for implementation in a program. [P2]
      • EK 4.1.1A - Sequencing, selection, and iteration are building blocks of algorithms.
      • EK 4.1.1B - Sequencing is the application of each step of an algorithm in the order in which the statements are given.
      • EK 4.1.1H - Different algorithms can be developed to solve the same problem.
    • LO 4.1.2 - Express an algorithm in a language. [P5]
      • EK 4.1.2A - Languages for algorithms include natural language, pseudocode, and visual and textual programming languages.
      • EK 4.1.2B - Natural language and pseudocode describe algorithms so that humans can understand them.
      • EK 4.1.2C - Algorithms described in programming languages can be executed on a computer.
      • EK 4.1.2G - Every algorithm can be constructed using only sequencing, selection, and iteration.
      • EK 4.1.2I - Clarity and readability are important considerations when expressing an algorithm in a language.
Big Idea - Programming
  • EU 5.2 - People write programs to execute algorithms.
    • LO 5.2.1 - Explain how programs implement algorithms. [P3]
      • EK 5.2.1H - A process may execute on one or several CPUs.

Math Common Core Practice:

  • MP1: Make sense of problems and persevere in solving them.
  • MP2: Reason abstractly and quantitatively.
  • MP7: Look for and make use of structure.

Common Core Math:

  • A-SSE.1-2: Interpret the structure of expressions
  • A-SSE.3-4: Write expressions in equivalent forms to solve problems

Common Core ELA:

  • RST 12.3 - Precisely follow a complex multistep procedure
  • RST 12.4 - Determine the meaning of symbols, key terms, and other domain-specific words and phrases
  • WHST 12.4 - Produce clear and coherent writing in which the development, organization, and style are appropriate to task, purpose, and audience

NGSS Practices:

  • 2. Developing and using models
  • 5. Using mathematics and computational thinking
  • 6. Constructing explanations (for science) and designing solutions (engineering)

Key Concepts

Students will provide a definition of "algorithm".

Students will identify the characteristics of describing algorithms in English, pseudocode, or a programming language.

Students will demonstrate an understanding that there are different algorithms for different situations, such as parallel processing for multiple CPUs.


Essential Questions

  • How are vastly different kinds of data, physical phenomena, and mathematical concepts represented on a computer?
  • How are algorithms implemented and executed on computers and computational devices?

 

 

Teacher Resources

Student computer usage for this lesson is: none

PowerPoint Slides for mini-lectures (AlgorithmsPseudocode1.pptx in the Lesson Resources folder)

Excel sheet summary for creating a 4-by-4 Magic Square (MagicSquare4by4.xls in the Lesson Resources folder)

(optional) 16 papers, each with a number from 1-16 on it for students to use when acting out the magic square. 

Lesson Plan

Getting Started (5 min)

  • Journal Entry Review

–Small group, then large group, review of two previous homework assignments (students were assigned to use two sources to find definitions of "algorithm" and were assigned to write down the steps involved in a daily task – creating a peanut butter and jelly sandwich; getting to school; brushing teeth; completing homework; etc…) The definitions, sources, and algorithm steps were to have been entered into their journal. 

- Have students consider solving problems alone or with others. Point out that some computers have more than one processor and an algorithm can be written to do 2 or more processes in parallel. Consider some complications that might arise in the simple algorithms that have been developed by students if there were multiple CPUs.

Activities (40 min)

  • Guided Activity 1

– Act out selected homework “steps of a daily task” to highlight the potential ambiguity of English instructions.

  • Mini-lecture 1

– Review Understanding by Design (UBD)-style slide for “Algorithms and Pseudocode: Need to Understand / Important to Know or Do / Worth Being Familiar With” (slide 2 of AlgorithmsPseudocode1.pptx presentation in Lesson Resources folder).

  • Guided Activity 2

– Class creates a 4-by-4 Magic Square, as described in MagicSquare4by4.xls in Lesson Resources folder. Sixteen students should be chosen to represent the sixteen numbers, and physically move into the 16 spaces following the algorithm in this document.  (This provides an example of a “simple” algorithm that solves a more complex problem; it also gets the students out of their seats and moving around).

Reflect: Would it be easier or harder for 2 people to work on this together? (multiple CPUs or parallel processing)

  • Mini-lecture 2

–In AlgorithmsPseudocode1.pptx (presentation in Lesson Resources folder), walk through “Main Ideas”; “Representing Algorithms”; and “Sequential Algorithms” slides, including pseudocode circle example.

Wrap Up (5 min)

  • Review concept of "algorithm"
  • Review concept of multiprocessor algorithms that use parallel processing.
  • Homework: Assign students to write pseudocode for selected algebraic computations.

Options for Differentiated Instruction

"In your words" pair/share as the concept of what an algorithm is (and what is not an algorithm -- e.g. "sort the numbers") is developed.

Class-wide development of the graphical organizer should be facilitated with scaffolding to support students who are having difficulty with the concept.


Evidence of Learning

Formative Assessment

The following "Checks for Understanding" could be used to guide the students towards the two learning objectives.

Objective: Students will be expected to learn to provide a definition of "algorithm".

  1. Example/Non-Example:  As the class develops a consensus definition of "algorithm," a list of daily living tasks and technical tasks will be discussed to see if their description can match the definition.
  2. Exit Ticket:  As students leave the room they will hand the teacher a definition of "algorithm", in their own words, plus an example.  The teacher will use these to guide the next day's instruction.

Objective:  Students will learn to identify the characteristics of describing algorithms in English, pseudocode, or in a programming language.

  1. Graphic Organizer:  As the characteristics of English, pseudocode, and a programming language are compared and contrasted, a table will be created on the board that captures the dimensions of what the students discuss.  The students will score the result as to how well it helps their understanding of the concept.  When it is "very good," we will capture it for their use.

Summative Assessment

Students will research formal definitions of algorithms.  These will be entered into their journals and pair-shared with a peer.

Students will write out the sequence of steps in one or more daily living tasks, such as "brushing their teeth" or "building a peanut butter and jelly sandwich."  These will be entered into their jourmals and pair-shared with a peer.  Selected solutions will be "acted out" in the classroom.

 

Lesson Summary

Pre-lesson Preparation

This is the second session on algorithms

Summary

During the second session, the students will use pseudocode to describe an algorithm.

Outcome

  • Students will write pseudocode using sequencing, selection, and iteration constructs.
  • Students will write pseudocode for algebra / geometry formulas.
  • Students will write pseudocode for determining if a year is a leap year.

Overview

  1. Getting Started (5 min)
  2. Guided Activities (40 min)
    1. PowerPoint
    2. Think-Pair-Share
    3. Solutions check
  3. Wrap Up (5 min)

Learning Objectives

CSP Objectives

Big Idea - Creativity
  • EU 1.1 - Creative development can be an essential process for creating computational artifacts.
    • LO 1.1.1 - Apply a creative development process when creating computational artifacts. [P2]
      • EK 1.1.1B - Creating computational artifacts employs an iterative and often exploratory process to translate ideas into tangible form.
  • EU 1.2 - Computing enables people to use creative development processes to create computational artifacts for creative expression or to solve a problem.
    • LO 1.2.5 - Analyze the correctness, usability, functionality, and suitability of computational artifacts. [P4]
      • EK 1.2.5B - A computational artifact may have weaknesses, mistakes, or errors depending on the type of artifact.
      • EK 1.2.5C - The functionality of a computational artifact may be related to how it is used or perceived.
      • EK 1.2.5D - The suitability (or appropriateness) of a computational artifact may be related to how it is used or perceived.
Big Idea - Abstraction
  • EU 2.2 - Multiple levels of abstraction are used to write programs or create other computational artifacts.
    • LO 2.2.1 - Develop an abstraction when writing a program or creating other computational artifacts. [P2]
      • EK 2.2.1A - The process of developing an abstraction involves removing detail and generalizing functionality.
      • EK 2.2.1B - An abstraction extracts common features from specific examples in order to generalize concepts.
      • EK 2.2.1C - An abstraction generalizes functionality with input parameters that allow software reuse.
Big Idea - Algorithms
  • EU 4.1 - Algorithms are precise sequences of instructions for processes that can be executed by a computer and are implemented using programming languages.
    • LO 4.1.1 - Develop an algorithm for implementation in a program. [P2]
      • EK 4.1.1A - Sequencing, selection, and iteration are building blocks of algorithms.
      • EK 4.1.1B - Sequencing is the application of each step of an algorithm in the order in which the statements are given.
      • EK 4.1.1C - Selection uses a Boolean condition to determine which of two parts of an algorithm is used.
      • EK 4.1.1D - Iteration is the repetition of part of an algorithm until a condition is met or for a specified number of times.
      • EK 4.1.1G - Knowledge of standard algorithms can help in constructing new algorithms.
      • EK 4.1.1H - Different algorithms can be developed to solve the same problem.
    • LO 4.1.2 - Express an algorithm in a language. [P5]
      • EK 4.1.2A - Languages for algorithms include natural language, pseudocode, and visual and textual programming languages.
      • EK 4.1.2B - Natural language and pseudocode describe algorithms so that humans can understand them.
      • EK 4.1.2C - Algorithms described in programming languages can be executed on a computer.
      • EK 4.1.2G - Every algorithm can be constructed using only sequencing, selection, and iteration.
      • EK 4.1.2H - Nearly all programming languages are equivalent in terms of being able to express any algorithm.
      • EK 4.1.2I - Clarity and readability are important considerations when expressing an algorithm in a language.
Big Idea - Programming
  • EU 5.2 - People write programs to execute algorithms.
    • LO 5.2.1 - Explain how programs implement algorithms. [P3]
      • EK 5.2.1A - Algorithms are implemented using program instructions that are processed during program execution.
      • EK 5.2.1B - Program instructions are executed sequentially.
      • EK 5.2.1C - Program instructions may involve variables that are initialized and updated, read, and written.
  • 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.1E - Logical concepts and Boolean algebra are fundamental to programming.

Math Common Core Practice:

  • MP1: Make sense of problems and persevere in solving them.
  • MP2: Reason abstractly and quantitatively.
  • MP7: Look for and make use of structure.

Common Core Math:

  • A-SSE.1-2: Interpret the structure of expressions
  • A-SSE.3-4: Write expressions in equivalent forms to solve problems
  • F-IF.1-3: Understand the concept of a function and use function notation
  • F-IF.4-6: Interpret functions that arise in applications in terms of the context

Common Core ELA:

  • RST 12.3 - Precisely follow a complex multistep procedure
  • WHST 12.4 - Produce clear and coherent writing in which the development, organization, and style are appropriate to task, purpose, and audience

NGSS Practices:

  • 2. Developing and using models
  • 5. Using mathematics and computational thinking
  • 6. Constructing explanations (for science) and designing solutions (engineering)

Key Concepts

Students will write pseudocode using sequencing, selection, and iteration constructs.


Essential Questions

  • How are vastly different kinds of data, physical phenomena, and mathematical concepts represented on a computer?
  • How are algorithms implemented and executed on computers and computational devices?
  • How do computer programs implement algorithms?

 

Teacher Resources

Student computer usage for this lesson is: optional

Files in the Lesson Resources folder:

AlgorithmsPseudocode2.pptx : PowerPoint Slides for mini-lectures

Student Handout and Key for Matching Pennies Game

Student Handout for Rock Paper Scissors

Psuedocode Summary and Examples of common Algorithms.docx

Lesson Plan

Getting Started (5 min)

  • Homework Review from Session 1 (students were assigned to write pseudocode for selected Algebra/Geometry calculations)
  • Journal: Describe the algorithm of another student. Is there enough detail to allow somebody to follow the steps?

Guided Activities (40 min)

PowerPoint

Walk through “Selection Statements”; “Iteration / Repetition” slides from the AlgorithmsPseudocode2 file in the Lesson Resources folder.

Things to stress with your students:

1.  Whenever you need to store information, it must go into a variable.  So think about what variables might be needed when you are creating your algorithm

2.  Selection and Iteration statements require conditionals.  Identify a conditional as something that returns a True or False answer.  If selects the next statement to occur by answering the conditional question as being true or false.  I have in the past pointed out the True and Then both start with T so TRUE always does the THEN, wherease Else and False both end with LSE, so when the answer if FALSE, you do the ELSE.

While continues to loop as long as the conditional answer is TRUE.  When the conditional answer is false, the  algorithm jumps to the statement after the End While.

3. Nearly all programming languages are equivalent in terms of being able to express any algorithm. Each has its own way to use variables, conditions and repetition which are needed for a solution to almost all algorithms.

Guided Activity

During powerpoint, guide students through the Game of Matching Pennies (a student working copy and a solution key is in the Master Teacher Resource folder for this lesson).  

Think-Pair-Share

Students work in pairs to create and share their pseudocode.  Use the Rock Paper Scissors hand out to have student pairs psuedocode Rock Paper Scissors.  If there is time, have groups switch algorithms and critique the algorithm of the other group.

Walk through pseudocode syntax summary handout called Pseudocode Summary and Examples of common Algorithms.docx in Lesson Resources folder.

Students work through challenges and check their results against sample solutions. 

Wrap Up (5 min)

Review slide: "Why we have leap years." 

Homework:

Assign students to create pseudocode for leap years.


Options for Differentiated Instruction

Pairing of students and crossing pairs to form groups of four should be used for the set of exercises that are part of this lesson.


Evidence of Learning

Formative Assessment

Think-Pair-Share


Summative Assessment

Students will write pseudocode for algebra / geometry formulas.  These will be entered into their class notes.

Students will write pseudocode for determining if a year is a leap year.  This will be entered into their journals.

Lesson Summary

Summary

Students learn simple Python programs and their structure, as well as the basics of debugging.

Outcomes

  • Students will identify the parts of a Python program
  • Students will describe the history of the computer bug.
  • Students will look at debugging techniques and classifying errors.
  • Students will compare different kinds of errors

Overview

Session 1:

  1. Getting Started (5 min) Discussion: What is a program?
  2. Guided Activity (40 min) Exploration
  3. Wrap Up (5 min)
  4. Homework

Session 2:

  1. Getting Started (20 min)
    1. Homework Review [5 min]
    2. Runestone Tutorial [15 min]
  2. Activity (20 min)
  3. Wrap Up (10 min) Journal
  4. Homework

Learning Objectives

CSP Objectives

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.1 - Develop a program for creative expression, to satisfy personal curiosity, or to create new knowledge. [P2]
      • EK 5.1.1A - Programs are developed and used in a variety of ways by a wide range of people depending on the goals of the programmer.
      • EK 5.1.1B - Programs developed for creative expression, to satisfy personal curiosity, or to create new knowledge may have visual, audible, or tactile inputs and outputs.
      • EK 5.1.1D - Additional desired outcomes may be realized independently of the original purpose of the program.
    • LO 5.1.2 - Develop a correct program to solve problems. [P2]
      • EK 5.1.2G - Program development includes identifying programmer and user concerns that affect the solution to problems.
      • EK 5.1.2J - A programmer designs, implements, tests, debugs, and maintains programs when solving problems.
  • EU 5.4 - Programs are developed, maintained, and used by people for different purposes.
    • LO 5.4.1 - Evaluate the correctness of a program. [P4]
      • EK 5.4.1C - Meaningful names for variables and procedures help people better understand programs.
      • EK 5.4.1E - Locating and correcting errors in a program is called debugging the program.
      • EK 5.4.1F - Knowledge of what a program is supposed to do is required in order to find most program errors.
      • EK 5.4.1G - Examples of intended behavior on specific inputs help people understand what a program is supposed to do.
      • EK 5.4.1H - Visual displays (or different modalities) of program state can help in finding errors.
      • EK 5.4.1I - Programmers justify and explain a program’s correctness.
      • EK 5.4.1M - The functionality of a program is often described by how a user interacts with it.
  • 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.1D - Mathematical expressions using arithmetic operators are part of most programming languages.

Math Common Core Practice:

  • MP2: Reason abstractly and quantitatively.
  • MP6: Attend to precision.
  • MP7: Look for and make use of structure.

Common Core ELA:

  • RST 12.3 - Precisely follow a complex multistep procedure
  • RST 12.4 - Determine the meaning of symbols, key terms, and other domain-specific words and phrases

NGSS Practices:

  • 5. Using mathematics and computational thinking

Key Concepts

Programs can be developed to solve problems (to help people, organizations or society), for creative expression, to satisfy personal curiosity or to create new knowledge.

Additional outcomes beyond the original purpose of a program are possible.


Essential Questions

  • How are programs used for creative expression, to satisfy personal curiosity or to create new knowledge?
  • How do computer programs implement algorithms?
  • How do people develop and test computer programs?
  • Which mathematical and logical concepts are fundamental to computer programming?

Teacher Resources

Student computer usage for this lesson is: required

For the Students:

    • "Is Eliza Human?"
    • CodingBat practice
        Useful once functions have been taught

http://codingbat.com/python

      Development environments for python
        Spyder Python Development Environment:

https://github.com/spyder-ide/spyder

        Python IdlePycharm Python Development Environment using Python 3.4.1
        Runestone: Interactive Python:

http://interactivepython.org/runestone/static/thinkcspy/index.html

Lesson Plan

Session 1

Getting Started (5 min)

Journal Prompt: What is a bug in a computer program?

  • See if anybody knows the history, this will be covered in Runestone General Introduction What is Debugging? lesson that follows.

Guided Activity (40 min)

  • Runestone Tutorial [30 min]

  • Jigsaw: Divide students up into 5 groups. Have each group prepare a creative presentation on one of the topics below with visuals or an active component (rap, song, dramatic reading, etc.) to convey the message of that section. Groups have 15 minutes to prepare a 2 minute presentation.
  • What is Debugging?
  • Syntax errors
  • Runtime Errors
  • Semantic Errors
  • Experimental Debugging

  • After the presentations all students should 
    1. make a tree diagram, name the three types of errors, and give examples of each. Which type of error do you think is the hardest to detect and why?
  • Explore a simple Python program together. [ 10 minutes]

    • Teacher demonstrates the results of running eliza.py using Pycharm or Idle 
    • Hand out the code for eliza.py on paper to students, demonstrate on the front screen have them mark up the code as indicated on the student handout together as a class discussing the vocabulary below (all of these concepts will be taught in Unit 2, this is just a preview).
      (See the teacher guide for answer key.)
    • Vocabulary: (use the Runestone Glossaries if needed)
      • comment
      • function: 
      • parameter
      • input
      • output
      • loop
      • condition
      • variable
    • Have students mark up the code at the bottom of the page using the same key on the student handout

Wrap Up (5 min)

Journal: Use formative assessment Questions 1 - 3:

  1. How do you make an output statement in Python?
  2. How do you make an input statement?
  3. What is a user prompt and what is its purpose?

Homework

Set up your IDE and Python at home (if you can) or use an online Python IDE such as https://repl.it/languages/Python3 or ideone.com . Type up a simple "Hello World" program and get it to run. Bring in evidence that it works or write a few sentences about the issues you are having in trying to install it or write about your experience using an online IDE, or write out the code for Hello World without looking at any notes and report on how easy or hard it was to remember the details. (Be careful not to make any student feel awkward for lack of a home computer they are allowed to install softare on)

Session 2

Getting Started (20 min)

Homework Review [5 min]

Collect handwritten notes or evidence that Python 3 is set up at home or the student is able to use https://repl.it/languages/Python3 or ideone.com. As students work on tutorial, address specific issues with students who had trouble with install.

Runestone Tutorial [15 min]

Complete an introductory tutorial:

Runestone Ch. 1 http://interactivepython.org/runestone/static/thinkcspy/GeneralIntro/toctree.html 

Activity (20 min)

Develop the beginnings of a chat bot where the computer and user introduce themselves to each other.  The computer asks a question, the user provides a response and the computer responds back again, including the user input within the response (see https://groklearning.com/csedweek/ for ideas). Extend: Give your chatbot a personality like a friend, grandfather, therapist, or child. 

Wrap Up (10 min)

Journal [10 min]

First discuss: How can additional desired outcomes happen independently of the original purpose of a program? (examples: a program like chatbot could help someone learn a new language, provide entertainment for a shut-in. Computer games can increase reflexes, logic skills, provide motivation for someone in physical therapy) 

Answer Formative assessment Questions # 4 - 6:

4) Name several different input devices.

5) How do we comment a Python program? Why do we use comments?

6) In your journal, make a tree diagram, name the three types of errors, and give examples of each. Which type of error do you think is the hardest to detect and why?

Homework

Write code to introduce yourself. Display your name. Greet and ask for three interests. Display the three interests and give a reply like "That's interesting!" Print your code. Next day: Have students introduce one another by “running the code" of a classmate. If you cannot get PyCharm to install, use http://ideone.com/ or repl.it or create this program by hand on paper.


Options for Differentiated Instruction

Suggested strategies:

  • Use red, yellow, green sticky notes at computer for a quick check of understanding.
  • Provide guide questions for reading during Runestone interactive tutorial.
  • Provide teacher-annotated text excerpts or have students annotate their own excerpts that follow the Runestone interactive.

Evidence of Learning

Formative Assessment

In your journal, make a tree diagram, name the three types of errors, and give examples of each. Which type of error do you think is the hardest to detect and why?


Summative Assessment

Find the errors in an algorithm or in Python statements covered to date

Define what debugging is and give examples of the 3 categories of bugs (syntax, logic(semantic) and runtime)

Describe the differences between programming and debugging.

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.

 

Lesson Summary

Summary

Students will learn to manipulate variables and value assignments through an activity in which they must become the variable.  By the end of the lesson, they will have identified variables as memory locations. They will also assign, copy, and destroy values in order to perform a swap algorithm and visualize Python's manipulation of variables and values in memory.

Outcomes

  • Students will learn about variable manipulation and assignment.
  • Students will understand variables representing memory locations.
  • Students will be able to use variables in Python.

Overview

  1. Getting Started (5 min) - Journal
  2. Introduction of Content (25 min) - Visualizing Variables
  3. Independent Activity (15 min) - "Swap to the Top"
  4. Wrap Up (5 min)

Learning Objectives

CSP Objectives

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.2 - Develop a correct program to solve problems. [P2]
      • EK 5.1.2B - Developing correct program components and then combining them helps in creating correct programs.
    • LO 5.1.3 - Collaborate to develop a program. [P6]
      • EK 5.1.3D - Collaboration can make it easier to find and correct errors when developing programs.
      • EK 5.1.3E - Collaboration facilitates developing program components independently.
  • EU 5.2 - People write programs to execute algorithms.
    • LO 5.2.1 - Explain how programs implement algorithms. [P3]
      • EK 5.2.1A - Algorithms are implemented using program instructions that are processed during program execution.
      • EK 5.2.1B - Program instructions are executed sequentially.
      • EK 5.2.1C - Program instructions may involve variables that are initialized and updated, read, and written.

Math Common Core Practice:

  • MP1: Make sense of problems and persevere in solving them.
  • MP2: Reason abstractly and quantitatively.
  • 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.3 - Precisely follow a complex multistep procedure
  • RST 12.4 - Determine the meaning of symbols, key terms, and other domain-specific words and phrases
  • WHST 12.1 - Write arguments on discipline specific content
  • WHST 12.2 - Write informative/explanatory texts, including the narration of historical events, scientific procedures/experiments, or technical processes
  • WHST 12.6 - Use technology, including the Internet, to produce, publish, and update writing products

NGSS Practices:

  • 1. Asking questions (for science) and defining problems (for engineering)
  • 5. Using mathematics and computational thinking

Key Concepts

  • Variables are memory locations that we have named, so we can put things in those locations.
  • Variables contain values, and can only contain one value at a time.
  • When assigning one variable from another, a copy is made rather than a transfer.
  • If a variable is being assigned after having been initialized to a previous value, that previous value is lost and no longer accessible unless that value has been copied to another variable space.
  • Programs implement algorithms. In order to accomplish a task: create a plan (algorithm), translate it into code and identify what kinds of information will be stored and maniuplated (variables)

Essential Questions

  • How are vastly different kinds of data, physical phenomena, and mathematical concepts represented on a computer?
  • How are programs developed to help people, organizations or society solve problems?
  • How do computer programs implement algorithms?

Teacher Resources

Student computer usage for this lesson is: none

For the Students:

  • Cups
  • Notecards
  • String and paper to create large name labels (could also use nametags)
  • Worksheet: "Swap to the Top.docx" (in the Lesson Resources folder)
  • Homework 

Optional:

  • Differentiated one-pager (see "Options for Differentiated Instruction" in lesson).

For the Teacher:

  • Write the following code on the board (after students have a chance to brainstorm their own solutions):
team1 = "Miami Heat"
team2 = "Washingon Wizards"
temp = team1
team1 = team2
team2 = temp

Lesson Plan

Getting Started (5 min)

Journal

What is a variable?  What are some things in your life that change often?

Introduction of Content (25 min)

Introduction of Variables [5 min]

See slides in Lesson Resources Folder for a guided introduction.

Guided Activity: Visualizing Variables [15 min]

Materials

Disposable cups, index cards, names for variables on strings (to hang around students' necks)

Setup

  1. We’re about to talk about sports teams and their ranking in terms of variables. When we place teams on a ranking board, Team 1 is always at the top, followed by Team 2, Team 3, etc.  Write a ranked set of 3 to 5 (real or invented) teams on the board. As they play one another, this ranking may change and someone new becomes Team 1.
  2. Ask for a student volunteer.  Give this volunteer a cup: they are now representing a new variable!  In order for a computer to know which variable is which, they need names . Variable names can be any sequence (beginning with a letter or underscore, and including no spaces), but usually we use words that describe what is inside the variable. (For example, if I have a variable for "student’s age," I’m not going to name it tree, because the word tree has no relevance to your age.)
  3. Label this variable team1 because we’re talking about sports teams. Put the name around the student’s neck to indicate they have become the variable team1. This student has now become team1, and should not respond to any other names! Note: A variable name will never have quotes around it - that would indicate that it is a string (i.e., a type of value rather than a variable's name).  Variables can be identified (loosely) by words or letters that are not in quotes and are not keywords (for, if, else, etc.).
  4. Next, we will assign a value to the variable.  This means we will store that value in the location team1.  Because we have never used this variable before, we are initializing it - putting something in this box (memory location) for the first time.  On the board, write team1 = "Miami Heat"
  5. CFU:  What is the type of "Miami Heat"?
    ("Miami Heat" is a string.  We know this because it has quotes around it.)
  6. The equals sign is what allows us to make this assignment.  We are not saying that team1 is the same as the Washington Wizards; it is only where were are currently keeping that team. Write “Miami Heat” on a notecard and put it into the cup.
  7. Next, we need to initialize  our second variable and assign a value to it. Follow the same process as team1 and "Miami Heat", this time using team2 and "Washington Wizards".
  8. CFU: What is the difference between a value and a variable?
    (Values can be stored in variables.  The content of a variable can change to different values, but its name will always be the same because the name is just an identifier of a location in memory.)
  9. We’ve now initialized our two variables, but as it turns out… last night the two teams played, and the order was upset, putting the Wizards ahead!  We have to model a swap in our code to reflect this change and fix our scoreboard.
  10. Think-Pair-Share: A value is only safe (and not lost to the world of cyberspace) if it is in a variable.  A variable can only hold one value at a time.  How can we swap values between team1 and team2?
    (Allow students 3 minutes to brainstorm.)
  11. Call on students and have them direct team1 and team2 to swap their values. Key point: when we access a variable and put its value in the place of another variable, that value is being copied.  By doing so, however, any previous value in the variable is lost.
  12. Ideally, a student will realize they must create another variable and do so, walking each other through the completion of the swap.  If not, you should guide them towards this discovery.
  13. CFU (if necessary): Cold call a student to create a third variable, temp.
    (Make sure to call up a third member of the class to become the variable temp.)
  14. If students have not at this point finished the swap, continue to walk them through the swap of a value to the temp variable, so the variables do not overwrite one another.
  15. Initialize a variable temp (named so because we will not be using it very long). Write temp = team1 on the board.  Notice that in this assignment, it looks like we are setting a variable equal to another variable.  Instead, we are setting the variable temp equal to the value inside the variable team1.  This means that the value is copied to a second location.
  16. Call a new volunteer to the floor.  Give them a cup and name them temp.
  17. Write a second notecard labeled "Miami Heat" and put it in the temp cup.
  18. Now that the "Miami Heat" value has been saved somewhere, we can swap "Washington Wizards" into team1. Write team1 = team2 on the board.
  19. Go to team2 and copy the text from the notecard onto a new one. Move to team1 and replace the previous notecard with this new one.
  20. A variable can only store one value at the time, which means that we’ve lost whatever was in team1. Rip up the notecard or throw it in the trash.
  21. Complete the final assignment of team2 = temp by following the same process.  

Synopsis

Look at the code written on the board and ask a student to walk us through each step.

CFU: Why did we create the variable temp?

(Because variables overwrite the values of one another, and if we were to just set team2 = team1 we would lose one of the values.)

Students should notice:

  • Variables are memory locations that we have named, so we can put things in those locations.
  • Variables contain values, and can only contain one value at a time.
  • When assigning one variable from another, a copy is made rather than a transfer.
  • If a variable is being assigned after having been initialized to a previous value, that previous value is lost and no longer accessible.

Discussion [5 min]

In reality, Python actually has a "shortcut syntax" that allows us to make this swap in one step. It looks like this:

a,b = b,a

If we wanted to swap the values in team1 with team2, we would simply have to write:

team1,team2  = team2, team1

Here, Python is doing exactly what we were doing.  It is internally creating a variable (which has no name but serves the same purpose as our temp variable), using it as a place holder, and then completing the swap.  

Think-Pair-Share

Why would the makers of Python build in this function?  What other uses does it have? 

Independent Activity (15 min)

A version of this worksheet can be found in the Lesson Resources folder, titled "Swap to the Top".

Give students a list of games that have been played by the teams on the board, and the resultant new ranking.  Have them create a piece of code that will reorganize the teams into the correct ranking.  (They can assume that the variables team1 ... team13 already exist and have been initialized to the Friday ranking.)  Give them the option of doing so through the use of manipulatives, or on their own paper.

Wrap Up (5 min)

Discuss: All computer programs can be broken down into smaller, simpler steps. By developing components, testing to be sure they are correct and combining them you can create complex, correct programs. Did students get a feeling for systematic development, and how to trace a program one step at a time to verify correctness? Distribute Exit Ticket in Lesson Resources Folder which asks students to figure out the values of variables hello and goodbye after the code in each exercises been executed.

Journal

What is the difference between a variable in a math class and in a computer science class?  What is the difference between a float and an integer? Why would you use one instead of the other?

Homework  

Continue working on "Swap to the Top" worksheet.


Options for Differentiated Instruction

Create a 3 column ‘one-pager’.  In the left column, create a copy of the code from the activity (a swap algorithm) including team1, team2, and temp that performs the complete swap.  In the middle column, write steps that occur in the code (Step 1: Initialize variable and assign the value).  In the third column, the students should draw a visual of what that looks like in terms of disposable cups and index cards. (They can just write the variable name on the cup, rather than drawing in a person as well.) 


Evidence of Learning

Formative Assessment

Checks for Understanding are embedded in the lesson.  They are also shared below.

What is the type of “Miami Heat”?

(“Miami Heat" is a string.  We know this because it has quotes around it .)

What is the difference between a value and a variable?

(Values can be stored in variables.  The content of a variable can change to different values, but its name will always be the same because the name is just an identifier of a location in memory.) 

Think-Pair-Share: A value is only safe (and not lost to the world of cyberspace) if it is in a variable.  A variable can only hold one value at a time.  How can we swap values between team1 and team2?

(various answers)

Why did we create the variable temp?

(Because variables overwrite the values of one another, and if we were to just set team2 = team1, we would lose one of the values.)


Summative Assessment

Task: Create a piece of code that will rearrange the ranking of the teams in order to reflect the outcome of previous games. (Independent Practice)

Lesson Summary

Summary 

Students will learn how programs can solve problems using the various types of conditional statements in Python programs.

Outcomes

  • Students will understand how conditional logic controls program flow.
  • Students will be able to solve problems that require conditional logic.
  • Students will be able to look for answers in documentation (API)

Overview

  1. Getting Started (5 min)
  2. Introduction of Content (30 min)
    1. Comparison operators [5 min]
    2. Logical operators [5 min]
    3. Conditional statements [20 min]
  3. Activity (10 min)
  4. Wrap-up (5 min)

Learning Objectives

CSP Objectives

Big Idea - Creativity
  • EU 1.2 - Computing enables people to use creative development processes to create computational artifacts for creative expression or to solve a problem.
    • LO 1.2.2 - Create a computational artifact using computing tools and techniques to solve a problem. [P2]
      • EK 1.2.2A - Computing tools and techniques can enhance the process of finding a solution to a problem.
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.2 - Develop a correct program to solve problems. [P2]
      • EK 5.1.2B - Developing correct program components and then combining them helps in creating correct programs.
      • EK 5.1.2I - A programmer's knowledge and skill affects how a program is developed and how it is used to solve a problem.
      • EK 5.1.2J - A programmer designs, implements, tests, debugs, and maintains programs when solving problems.
  • EU 5.3 - Programming is facilitated by appropriate abstractions.
    • LO 5.3.1 - Use abstraction to manage complexity in programs. [P3]
      • EK 5.3.1M - Application program interfaces (APIs) and libraries simplify complex programming tasks.
      • EK 5.3.1N - Documentation for an API/library is an important aspect of programming.
  • EU 5.4 - Programs are developed, maintained, and used by people for different purposes.
    • LO 5.4.1 - Evaluate the correctness of a program. [P4]
      • EK 5.4.1C - Meaningful names for variables and procedures help people better understand programs.
      • EK 5.4.1E - Locating and correcting errors in a program is called debugging the program.
      • EK 5.4.1F - Knowledge of what a program is supposed to do is required in order to find most program errors.
      • EK 5.4.1G - Examples of intended behavior on specific inputs help people understand what a program is supposed to do.
      • EK 5.4.1I - Programmers justify and explain a program’s correctness.
      • EK 5.4.1L - An explanation of a program helps people understand the functionality and purpose of it.
      • EK 5.4.1M - The functionality of a program is often described by how a user interacts with it.
  • 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.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.
      • EK 5.5.1G - Intuitive and formal reasoning about program components using Boolean concepts helps in developing correct programs.

Math Common Core Practice:

  • MP1: Make sense of problems and persevere in solving them.
  • MP2: Reason abstractly and quantitatively.
  • 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.2 - Determine central ideas and conclusions in the text
  • RST 12.3 - Precisely follow a complex multistep procedure
  • RST 12.4 - Determine the meaning of symbols, key terms, and other domain-specific words and phrases
  • RST 12.9 - Synthesize information from a range of sources
  • RST 12.10 - Read and comprehend science/technical texts
  • WHST 12.2 - Write informative/explanatory texts, including the narration of historical events, scientific procedures/experiments, or technical processes

Key Concepts

Decisions in programs are made using conditional statements.


Essential Questions

  • How are programs developed to help people, organizations or society solve problems?
  • How do computer programs implement algorithms?
  • How do people develop and test computer programs?
  • Which mathematical and logical concepts are fundamental to computer programming?

How are comparison operators and Boolean expressions used with conditional statements?

Teacher Resources

Student computer usage for this lesson is: required

Lesson Plan

Getting Started (5 min)

Journal

Think of a decision you make in your daily life and how you make the decision.  In your journal, write about your decision and the process you use to decide.

Teaching note: take a few minutes to have students share responses (whole class, elbow partners, small groups).

Introduction of Content (30 min)

Brief discussion of comparison operators [5 min]

==, !=, <, >, >=, <=

Briefly discuss logical operators [5 min]

Includes AND, OR, and NOT

Example: Type various combinations of Boolean values (True / False) with Boolean operators (not, and, or) into the IDE (PyCharm)

Conditional Statements [20 min]

Show physical representation using real-life example

Suggested Activity: What’s in the box?

Materials: Two small opaque containers, one small item for each container, two post-it notes.

Set-Up Directions: Set up the activity before the class arrives, following the directions below:

  1. Place one item in each container.
  2. Using the post-it notes, label one box "green" and the other "black."
  3. On the board, write the two colors (green and black) on the board to record the student tally.
  4. On the board, write the following pseudocode:
    if numofGreen > numofBlack:
        open green box
    else:
        open black box

Activity Directions:

  1. Ask: “If you could choose one of these colors, which one would it be? Please only vote once.  Raise your hand if you would choose Green." Record the number of students who voted for Green on the board.
  2. Ask: “Raise your hand if you would choose Black.” Record those votes.
  3. Show the students the pseudocode on the board and work through the if/else statement using the data collected from the class.
  4. Open the box and display the item that the class voted for.

Discussion of Conditional Execution (if, if/else) 

Show the example from How to Think Like a Computer Scientist text (ActiveCode:6 (ch05_4)) or similar example.  Briefly demonstrate how to read flowcharts while showing the example from How to Think Like a Computer Scientist. Point out that the API (https://docs.python.org/3/library/) is always available as a language reference to help translate from algorithms/flowcharts into code. The API describes many tools to make it easier to create programs, and is an important tool for all programmers.

Check for understanding: Have students answer to the following questions:

1. What will be printed by the following code segment?

x=15
if x==25:
  print ('Pizza is yummy')
else:
   print ('My teacher is awesome')

2. What will be printed by the following code segment?

x=35
y=52
if x!=25 and y==52:
  print ('Pizza is yummy')
else:
('My teacher is awesome')

Use IDE (PyCharm) to show how to create an if/else statement

Suggested Coding Example:

n = input('Please enter your password: ')
if n=='P@s5w0d':
print ('Welcome, correct user!')
else:
print ('Incorrect, try again')

Activity (10 min)

Journal: Making Predictions [2 min]

Give the students the practice problem from Independent Activity 1 below.  Have the students answer the following questions:

  1. You are about to create a program using the given criteria. In your opinion, what is the purpose of this program?
  2. What do you think the output of  this program is when the food variable contains the following values?
    pizza
    popcorn 

Independent Activity 1 [8 minutes]

If/else practice problem: In the IDE, write a program that will prompt a user to enter a value for a food item. Evaluate the variable food. If the value of food is equal to “potato salad,” display “In Stock”.  If the value of food is not equal to “potato salad,” display “Not in Stock”.

Test your program with the following values for food:

pizza
popcorn
potato salad

Wrap Up (5 min)

Journal

Thinking about conditional execution, answer the following questions.

  1. What difficulties, if any, did you encounter during the development of your program?
  2. After running your independent program, were your predictions correct?
  3. What conditional execution concepts do you need clarified?
  4. How is it helpful to have a reference available for each programming language?

Options for Differentiated Instruction

Alternate Instructional Strategy for Guided Practice :

  • For guided practice, have a list of instructions for how to write the example presented.

Alternate Instructional Strategy for Journal: Interactive Journaling

  • Comment on the journal entry by asking check-for-understanding questions or clarifying any misconceptions students write about.

 


Evidence of Learning

Formative Assessment

  • A variety of checking for understanding techniques
    • Temperature checks
    • Teacher review student's code
    • Thumbs up/ thumbs down 
    • Questioning thoughout the lesson (whole group / small group / individual)
  • Quick quizzes
  • Interactive journaling

Summative Assessment

  • Students create a small program demonstrating conditional execution
  • Reflective journal entry

Lesson Summary

Pre-lesson preparation

Students must have an understanding of using conditional statements, and have completed all the assignments from Lesson 2-8.

Summary

Students will learn how programs can solve problems using nested and chained conditional statements in Python programs.

Outcomes

  • Students will understand how nested and chained conditional logic controls program flow.
  • Students will be able to solve problems that require nested and chained conditional logic.
  • Students will work collaboratively, resolve conflicts and facilitate group work to create a small program.
  • Students will use their journals to record answers and check for understanding and reflection.

Overview

  1. Getting Started (5 min)
  2. Introduction of Content (30 min)
    1. Conditional Statements [10 min]
    2. Nested Conditional Statements [15 min]
    3. Chained Conditional Statements [5 min]
  3. Activity (10 min)
  4. Wrap-up (5 min) 

Learning Objectives

CSP Objectives

Big Idea - Creativity
  • EU 1.2 - Computing enables people to use creative development processes to create computational artifacts for creative expression or to solve a problem.
    • LO 1.2.1 - Create a computational artifact for creative expression. [P2]
      • EK 1.2.1B - Creating computational artifacts requires understanding of and use of software tools and services.
    • LO 1.2.2 - Create a computational artifact using computing tools and techniques to solve a problem. [P2]
      • EK 1.2.2A - Computing tools and techniques can enhance the process of finding a solution to a problem.
    • LO 1.2.4 - Collaborate in the creation of computational artifacts. [P6]
      • EK 1.2.4A - A collaboratively created computational artifact reflects effort by more than one person.
      • EK 1.2.4C - Effective collaborative teams practice interpersonal communication, consensus building, conflict resolution, and negotiation.
      • EK 1.2.4D - Effective collaboration strategies enhance performance.
Big Idea - Algorithms
  • EU 4.1 - Algorithms are precise sequences of instructions for processes that can be executed by a computer and are implemented using programming languages.
    • LO 4.1.1 - Develop an algorithm for implementation in a program. [P2]
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.2 - Develop a correct program to solve problems. [P2]
      • EK 5.1.2C - Incrementally adding tested program segments to correct working programs helps create large correct programs.
      • EK 5.1.2I - A programmer's knowledge and skill affects how a program is developed and how it is used to solve a problem.
      • EK 5.1.2J - A programmer designs, implements, tests, debugs, and maintains programs when solving problems.
    • LO 5.1.3 - Collaborate to develop a program. [P6]
  • EU 5.2 - People write programs to execute algorithms.
    • LO 5.2.1 - Explain how programs implement algorithms. [P3]
      • EK 5.2.1A - Algorithms are implemented using program instructions that are processed during program execution.
      • EK 5.2.1B - Program instructions are executed sequentially.
      • EK 5.2.1C - Program instructions may involve variables that are initialized and updated, read, and written.
      • EK 5.2.1D - An understanding of instruction processing and program execution is useful for programming.
      • EK 5.2.1E - Program execution automates processes.
  • EU 5.4 - Programs are developed, maintained, and used by people for different purposes.
    • LO 5.4.1 - Evaluate the correctness of a program. [P4]
      • EK 5.4.1A - Program style can affect the determination of program correctness.
      • EK 5.4.1C - Meaningful names for variables and procedures help people better understand programs.
  • 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.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.1G - Intuitive and formal reasoning about program components using Boolean concepts helps in developing correct programs.

Math Common Core Practice:

  • MP1: Make sense of problems and persevere in solving them.
  • MP2: Reason abstractly and quantitatively.
  • MP5: Use appropriate tools strategically.
  • MP6: Attend to precision.
  • MP7: Look for and make use of structure.

Common Core ELA:

  • WHST 12.2 - Write informative/explanatory texts, including the narration of historical events, scientific procedures/experiments, or technical processes
  • WHST 12.9 - Draw evidence from informational texts to support analysis, reflection, and research

NGSS Practices:

  • 1. Asking questions (for science) and defining problems (for engineering)
  • 3. Planning and carrying out investigations
  • 4. Analyzing and interpreting data
  • 5. Using mathematics and computational thinking
  • 8. Obtaining, evaluation, and communicating information

Key Concepts

Students must know that conditional statements can be used inside of other condtional statements using nested and chained conditional statements.

Vocabulary:

  • nested conditional statements
  • chained conditional statements

Essential Questions

  • How are programs developed to help people, organizations or society solve problems?
  • How do computer programs implement algorithms?
  • How do people develop and test computer programs?
  • Which mathematical and logical concepts are fundamental to computer programming?

Teacher Resources

Student computer usage for this lesson is: required

In the Lesson Resources Folder:

  • Nested If Statement Setup

Reference Text:

Project Ideas:

Lesson Plan

Getting Started (5 min)

In your journal, write what will be displayed by the following code segment.  How do you know your answer is correct?

x=2500
if x < 1000:
   print(“small number”)
else:
   print(“big number”)

 

Introduction of Content (30 min)

Brief introduction to conditional statements (10 min)

Suggested Activity: What’s in the box? (Part 2)

Show physical representation using real life example by revisiting the box example from previous lesson:

Materials: Four small opaque containers, four small items, two opaque containers big enough to fit two small opaque containers, Six post it notes to label each container with a color

Set Up Directions: Set up the activity before the class arrives following the directions below:

  1. Place one small item in each small container
  2. With the post-it notes, label the four small containers with different color names (red, orange, yellow, green)
  3. Place two labeled containers in each of the larger containers
  4. With the remaining post it notes, label one box blue and the other indigo.
  5. On the board, write the color names on the board to record the student tally.
  6. On the board, write the following pseudocode:
if numofBlue > numofIndigo
if numofRed > NumofOrange
open red box
else
open orange box
else
if numofYellow > NumofGreen
open yellow box
else
open green box

The Activity Directions

  1. Ask: “If you could choose one of these colors, which one would it be. Please only vote once.  Raise your hand if you would choose Blue. Record the number of students who voted for Blue on the board.
  2. Ask: “Raise your hand if you would choose Indigo.” Record the number of students who voted for Indigo on the board.
  3. Show the students the pseudocode on the board and work through the if/else statement using the the data collected from the class.
  4. Open the the box and display the contents of the box  the class voted for.
  5. Have students repeat the voting procedure to choose which smaller box to choose and show the object they chose

Brief discussion on nested conditional statements (15 min)

Demonstrate the coding process of the example below. 

Guided Activity 1 - Coding Example:  Write a program that evaluates a variable "age" and displays a group age category (you are not an adult, you are a senior citizen or you are an adult.)Suggested Instructional Strategy - Think Aloud - model your thought process for solving this problem.  Include comments in your code.

age = 18
if age < 18:
  print(“you are not an adult”)
else:
  if age is > 65:
      print(“you are a senior citizen”)
  else:
      print(“you are an adult”)

Brief discussion on chained conditional statements (elif) (5 min)

Guided Activity 2 - Coding Example:

Write a program that prompts the user for their age and displays their age category ( you are not an adult, you are a senior citizen or you are an adult.)  If they are older than 200 display a message that reads "humanly impossible".

age = int(input("How old are you"))
if age < 18:
  print("you are not an adult")
elif age > 200:
  print("humanly impossible")
elif age >= 65:
  print("you are a senior citizen")
else:
  print("you are an adult")

Check for understanding

Assign students random numbers from 0 - 250.  Have students decide what group they belong to (child, adult, senior citizen, not human) and explain why they made their choice.  *** You could have students physically move into the groups, hold up a sign with their answer or answer quietly in their journal.  

Activity (10 min)

Collaborative Coding (10 minutes)

  1. Review group work requirements: all members contribute, resolve conflicts internally before asking the teacher for help, facilitate the contribution of all team members. Work together to decide how to divide up the work so that all group members contribute significantly to the process. Suggested roles: driver/navigator, timer, tester, journalist (recorder).
  2. In your group, develop the pseudocode for the following problem:
        A year is a leap year if it is divisible by 4 unless it is a century that is not divisible by 400. Write a function that takes a year as a parameter and returns True if the year is a leap year, False otherwise.
  3. In your group, write the program for the problem.  

***Note 

It is recommended that:

All partners should be actively involved in the program development. For example, you may choose to employ Pair Programming, in which one partner “drives” (types and uses the mouse) while the other “navigates” (reviews and helps to guide what the driver is doing), with the partners changing roles every 20 minutes. Another method of collaboration is for each partner to develop pieces of the program, combine those pieces, and provide frequent feedback to each other during the development process.

-The College Board Computer Science Principles, Performance Assessment ©2014

 

Wrap Up (5 min)

Journal

Thinking about Nested and Chained Conditional Statements, answer the following questions:

  1. What difficulties, if any did you encounter during development of your program?
  2. What difficulties, if any, did you encounter with your partner.
  3. If any difficulties did arise, what do you think are some strategies to eliminate the difficulties
  4. What concepts in this lesson do you need clarified?

Options for Differentiated Instruction

 Extensions

Homework 

  • Extension can be assigned as Homework

Alternate Instructional Strategy:

  • For guided practice, have a list of list of instructions for how to write the example presented
  • Think Aloud - Model your thought process while solving the guided practice problems

Alternate Instructional Strategy: Interactive Journaling

  • Comment on the journal entry by asking check for understanding questions or clarifying any misconceptions students write about.

Evidence of Learning

Formative Assessment

  • A variety of checking for understanding techniques
    • Temperature checks
    • Teacher review student's code
    • Thumbs up/ thumbs down
    • Questioning throughout the lesson (whole group / small group / individual)
  • Quick quizzes
  • Peer review
  • Interactive journaling

Summative Assessment

Students will create a collaborative program demonstrating concepts introduced in this two part lesson. Students will be assessed using a rubric and will reflect on their learning in their journal

Lesson Summary

Summary

In this lesson, students will be introduced to the concepts of iteration and for loops.

Outcomes

  • Students will work through a guided tutorial on for loops while being introduced to using turtle graphics in Python.
  • Students will practice writing programs using for loops and turtle graphics.  
  • Students will journal as a reflective tool to make a personal connection between iteration and their personal life.  
  • Students will describe how computation facilitates the creation and modification of computational artifacts with enhanced detail and precision.

Overview

  1. Getting Started (5 min)
  2. Introduction of Content (40 min)
    1. Activity [10 min]
    2. Journal [5 min]
    3. Activity [10 min]
    4. Individual Coding [15 min]
  3. Wrap Up (5 min)

 

Note: Turtle graphic examples in this lesson work with the community version of the PyCharm IDE and Python 3.4.1.

Learning Objectives

CSP Objectives

Big Idea - Creativity
  • EU 1.1 - Creative development can be an essential process for creating computational artifacts.
    • LO 1.1.1 - Apply a creative development process when creating computational artifacts. [P2]
      • EK 1.1.1A - A creative process in the development of a computational artifact can include, but is not limited to, employing nontraditional, nonprescribed techniques; the use of novel combinations of artifacts, tools, and techniques; and the exploration of personal curiosities.
      • EK 1.1.1B - Creating computational artifacts employs an iterative and often exploratory process to translate ideas into tangible form.
  • EU 1.2 - Computing enables people to use creative development processes to create computational artifacts for creative expression or to solve a problem.
    • LO 1.2.3 - Create a new computational artifact by combining or modifying existing artifacts. [P2]
      • EK 1.2.3A - Creating computational artifacts can be done by combining and modifying existing artifacts or by creating new artifacts.
      • EK 1.2.3B - Computation facilitates the creation and modification of computational artifacts with enhanced detail and precision.
  • EU 1.3 - Computing can extend traditional forms of human expression and experience.
    • LO 1.3.1 - Use computing tools and techniques for creative expression. [P2]
      • EK 1.3.1D - Digital effects and animations can be created by using existing software or modified software that includes functionality to implement the effects and animations.
Big Idea - Algorithms
  • EU 4.1 - Algorithms are precise sequences of instructions for processes that can be executed by a computer and are implemented using programming languages.
    • LO 4.1.2 - Express an algorithm in a language. [P5]
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.2 - Develop a correct program to solve problems. [P2]
      • EK 5.1.2A - An iterative process of program development helps in developing a correct program to solve problems.
      • EK 5.1.2C - Incrementally adding tested program segments to correct working programs helps create large correct programs.
  • EU 5.4 - Programs are developed, maintained, and used by people for different purposes.
    • LO 5.4.1 - Evaluate the correctness of a program. [P4]
      • EK 5.4.1E - Locating and correcting errors in a program is called debugging the program.
      • EK 5.4.1F - Knowledge of what a program is supposed to do is required in order to find most program errors.
      • EK 5.4.1G - Examples of intended behavior on specific inputs help people understand what a program is supposed to do.
      • EK 5.4.1H - Visual displays (or different modalities) of program state can help in finding errors.
  • 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.1E - Logical concepts and Boolean algebra are fundamental to programming.
      • EK 5.5.1G - Intuitive and formal reasoning about program components using Boolean concepts helps in developing correct programs.

Math Common Core Practice:

  • MP1: Make sense of problems and persevere in solving them.
  • MP2: Reason abstractly and quantitatively.
  • MP4: Model with mathematics.
  • MP5: Use appropriate tools strategically.
  • MP6: Attend to precision.
  • MP7: Look for and make use of structure.
  • MP8: Look for and express regularity in repeated reasoning.

Common Core ELA:

  • WHST 12.2 - Write informative/explanatory texts, including the narration of historical events, scientific procedures/experiments, or technical processes
  • WHST 12.4 - Produce clear and coherent writing in which the development, organization, and style are appropriate to task, purpose, and audience

NGSS Practices:

  • 3. Planning and carrying out investigations
  • 5. Using mathematics and computational thinking
  • 6. Constructing explanations (for science) and designing solutions (engineering)
  • 8. Obtaining, evaluation, and communicating information

Key Concepts

Students must understand that programs use the concept of iteration to perform repeated tasks.


Essential Questions

  • How can computing and the use of computational tools foster creative expression?
  • How can computing extend traditional forms of human expression and experience?
  • How are programs used for creative expression, to satisfy personal curiosity or to create new knowledge?
  • How do computer programs implement algorithms?
  • How do people develop and test computer programs?
  • Which mathematical and logical concepts are fundamental to computer programming?

Teacher Resources

Student computer usage for this lesson is: required

In the Lesson Resources folder:

  • Turtle Graphics Guided Activity

Required materials:

  • 5-10 objects that can be stacked (lego, duplo blocks, plastic cups…) for the first guided activity

Useful additional resources:

Lesson Plan

Getting Started (5 min)

Journal: Think about events in your life that require a repeated action.  They could be something simple such as eating a bowl of cereal.  List two events in your life that require an action to be repeated.  What is the action?  What prompts the need for the action to happen? How often does the action happen?

Note: Students will extend their reflections later in the lesson.

Introduction of Content (40 min)

Guided Activity:  Physical representation of iteration [10 min]

Materials:  5-10 objects that can be stacked (lego, duplo blocks, plastic cups…)

The activity:  Place the objects on a table.  

1.Say: “At the conclusion of this activity, all of the objects will be stacked.”

Chose one object to begin with.

2. Say: “I will start with this object and I will continue to stack until there are no single objects left on the table.  How many times do you think I will stack an object?  Why?”

3. Ask: "Are there any single objects on the table?”

Students should answer yes.  Stack one object on your beginning object

4. Ask “ Are there any single objects on the table?”

Students should answer yes.  Stack one more object on your started stack.  Continue to ask if there are any single objects on the table until the stack is completed and there are no more single objects on the table. Keep a tally of how many times you repeated the process.

5. Ask: “How many times did we repeat the process?  Did your prediction match the result?"

6. Explain to the students how the activity represents the concept of iteration and continue into the discussion of iteration.

  1. Ask: “How much better is a computer at providing accurate and detailed results of a very long, repetitive process?" "Why is a computer able to be more precise and detailed?"

    Computers are used in assembly lines and other places with lots of repetition because they can be almost perfectly accurate thanks to sensors that can be calibrated to the millimeter, and without needing to take a break.

Journal [5 min]

Choose one of the events you wrote about in your previous journal entry.  Take a moment to write the pseudocode for the repetitive action associated with that event.

Note: Check for understanding while students are working.

Example: Eating a slice of pizza:

 While pizza on plate

      pick up from plate

      take a bite

      place on plate

      bite is consumed

      loop

Guided Activity (for loops, how for loops use lists, range, turtle graphic) [10 min]

This guided activity introduces students to for loops using turtle graphics.

(See handout in Lesson Resources folder: Turtle Graphics Guided Activity: The for loop)

Individual Coding Activity [15 min]

Give students the following code stem. Have the students alter the code to perform the listed tasks.

Code Stem:

import turtle    # Allows us to use the turtles library

window = turtle.Screen()  # Creates a window to display graphics

bob = turtle.Turtle()   # creates a turtle named bob

#Write your code here

window.exitonclick()      # Exits the window when clicked

1. Have the turtle draw a triangle using a turtle

2. Now that you know how to add turtles and program them to draw lines repeatedly, use your imagination and creative ability to create your own picture using multiple for loops and turtles.

Wrap Up (5 min)

Journal:  In your journal summarize the process you used to create your picture. What problems did you encounter? What concepts do you need clarified?

 


Options for Differentiated Instruction

Students can be given a copy of the guided activity handout to follow along.

 


Evidence of Learning

Formative Assessment

a variety of checking for understanding techniques

    • temperature checks
    • teacher review student's code
    • thumbs up/ thumbs down
    • questioning throughout the lesson (whole group / small group / individual)

quick quizzes

peer review

interactive journaling


Summative Assessment

Students will use for loops and turtle graphics to create graphic representations of iteration.   They modify a code stem using turtle graphics to: 

1. draw a triangle

2. draw a picture using multiple for loops and turtles.

Lesson Summary

Summary

Students continue learning about iteration by using while loops and nested iteration. Students work through a guided tutorial on while loops and learn more turtle graphics features.  They also have the opportunity to practice collaboratively writing programs using for loops, while loops, and turtle graphics.  Throughout the lesson, students are given the opportunity to use their journal as a reflective tool.

Outcomes

  • Students will know that iteration can be performed in Python using while loops.  
  • Students will understand that for and while loops can be written (nested) inside of other for and while loops.
  • Students will share the workload by providing contributions to an overall collaborative effort.

Outline

  1. Getting Started (5 min)
  2. Guided Activity (15 min) - for and while loops with turtle graphics
  3. Collaborative Activity (25 min) - Shared coding of an iterative program
  4. Wrap Up (5 min) - Journal Activity

Learning Objectives

CSP Objectives

Big Idea - Creativity
  • EU 1.1 - Creative development can be an essential process for creating computational artifacts.
    • LO 1.1.1 - Apply a creative development process when creating computational artifacts. [P2]
      • EK 1.1.1B - Creating computational artifacts employs an iterative and often exploratory process to translate ideas into tangible form.
  • EU 1.2 - Computing enables people to use creative development processes to create computational artifacts for creative expression or to solve a problem.
    • LO 1.2.1 - Create a computational artifact for creative expression. [P2]
      • EK 1.2.1E - Creative expressions in a computational artifact can reflect personal expressions of ideas or interests.
    • LO 1.2.2 - Create a computational artifact using computing tools and techniques to solve a problem. [P2]
      • EK 1.2.2A - Computing tools and techniques can enhance the process of finding a solution to a problem.
    • LO 1.2.3 - Create a new computational artifact by combining or modifying existing artifacts. [P2]
      • EK 1.2.3A - Creating computational artifacts can be done by combining and modifying existing artifacts or by creating new artifacts.
    • LO 1.2.4 - Collaborate in the creation of computational artifacts. [P6]
      • EK 1.2.4A - A collaboratively created computational artifact reflects effort by more than one person.
      • EK 1.2.4D - Effective collaboration strategies enhance performance.
      • EK 1.2.4E - Collaboration facilitates the application of multiple perspectives (including sociocultural perspectives) and diverse talents and skills in developing computational artifacts.
      • EK 1.2.4F - A collaboratively created computational artifact can reflect personal expressions of ideas.
Big Idea - Algorithms
  • EU 4.1 - Algorithms are precise sequences of instructions for processes that can be executed by a computer and are implemented using programming languages.
    • LO 4.1.1 - Develop an algorithm for implementation in a program. [P2]
      • EK 4.1.1A - Sequencing, selection, and iteration are building blocks of algorithms.
      • EK 4.1.1B - Sequencing is the application of each step of an algorithm in the order in which the statements are given.
      • EK 4.1.1C - Selection uses a Boolean condition to determine which of two parts of an algorithm is used.
      • EK 4.1.1D - Iteration is the repetition of part of an algorithm until a condition is met or for a specified number of times.
      • EK 4.1.1F - Using existing correct algorithms as building blocks for constructing a new algorithm helps ensure the new algorithm is correct.
      • EK 4.1.1G - Knowledge of standard algorithms can help in constructing new algorithms.
      • EK 4.1.1H - Different algorithms can be developed to solve the same problem.
      • EK 4.1.1I - Developing a new algorithm to solve a problem can yield insight into the problem.
    • LO 4.1.2 - Express an algorithm in a language. [P5]
      • EK 4.1.2A - Languages for algorithms include natural language, pseudocode, and visual and textual programming languages.
      • EK 4.1.2C - Algorithms described in programming languages can be executed on a computer.
      • EK 4.1.2G - Every algorithm can be constructed using only sequencing, selection, and iteration.
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.1 - Develop a program for creative expression, to satisfy personal curiosity, or to create new knowledge. [P2]
      • EK 5.1.1A - Programs are developed and used in a variety of ways by a wide range of people depending on the goals of the programmer.
      • EK 5.1.1B - Programs developed for creative expression, to satisfy personal curiosity, or to create new knowledge may have visual, audible, or tactile inputs and outputs.
      • EK 5.1.1C - Programs developed for creative expression, to satisfy personal curiosity, or to create new knowledge may be developed with different standards or methods than programs developed for widespread distribution.
      • EK 5.1.1D - Additional desired outcomes may be realized independently of the original purpose of the program.
    • LO 5.1.2 - Develop a correct program to solve problems. [P2]
    • LO 5.1.3 - Collaborate to develop a program. [P6]
  • EU 5.2 - People write programs to execute algorithms.
    • LO 5.2.1 - Explain how programs implement algorithms. [P3]
      • EK 5.2.1A - Algorithms are implemented using program instructions that are processed during program execution.
      • EK 5.2.1B - Program instructions are executed sequentially.
      • EK 5.2.1C - Program instructions may involve variables that are initialized and updated, read, and written.
      • EK 5.2.1D - An understanding of instruction processing and program execution is useful for programming.
      • EK 5.2.1E - Program execution automates processes.
  • EU 5.4 - Programs are developed, maintained, and used by people for different purposes.
    • LO 5.4.1 - Evaluate the correctness of a program. [P4]
      • EK 5.4.1E - Locating and correcting errors in a program is called debugging the program.
      • EK 5.4.1F - Knowledge of what a program is supposed to do is required in order to find most program errors.
      • EK 5.4.1G - Examples of intended behavior on specific inputs help people understand what a program is supposed to do.
      • EK 5.4.1H - Visual displays (or different modalities) of program state can help in finding errors.
      • EK 5.4.1I - Programmers justify and explain a program’s correctness.
  • 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.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.
      • EK 5.5.1G - Intuitive and formal reasoning about program components using Boolean concepts helps in developing correct programs.

Math Common Core Practice:

  • MP1: Make sense of problems and persevere in solving them.
  • MP2: Reason abstractly and quantitatively.
  • MP5: Use appropriate tools strategically.
  • 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.3 - Precisely follow a complex multistep procedure
  • RST 12.4 - Determine the meaning of symbols, key terms, and other domain-specific words and phrases
  • RST 12.9 - Synthesize information from a range of sources
  • WHST 12.2 - Write informative/explanatory texts, including the narration of historical events, scientific procedures/experiments, or technical processes

NGSS Practices:

  • 3. Planning and carrying out investigations
  • 5. Using mathematics and computational thinking
  • 6. Constructing explanations (for science) and designing solutions (engineering)
  • 8. Obtaining, evaluation, and communicating information

Key Concepts

  • Students will describe how iteration can be performed in Python using while loops.  
  • Students will demonstrate that for and while loops can be written (nested) inside of other for and while loops.
  • Students will describe programs that are developed for creative expression, to satisfy personal curiosity, or to create new knowledge and that these programs may be developed with different standards or methods than programs developed for widespread distribution.
  • Students will work together to facilitate collaborative work.

Essential Questions

  • How can computing and the use of computational tools foster creative expression?
  • How are programs developed to help people, organizations or society solve problems?
  • How are programs used for creative expression, to satisfy personal curiosity or to create new knowledge?
  • How do people develop and test computer programs?
  • Which mathematical and logical concepts are fundamental to computer programming?

Teacher Resources

Student computer usage for this lesson is: required

In the Lesson Resources folder:

  • Guided activity: "Turtle Graphics Guided Activity: The while loop" in the Lesson Resources folder

Other:

Lesson Plan

Getting Started (5 min)

What will be displayed at the end of this program?

y=0
for x in range (0, 8):
   y += 1 print (y)

Introduction of Content (15 min)

  • Use the guided activity ("Turtle Graphics Guided Activity: The while loop" in the lesson folder) to discuss while loops and nested iteration.
  • To save time, have these programs open in your IDE before class starts.

Collaborative Coding Activity (25 min)

Have students work together to complete a coding activity that uses while loops, for loops, and/or nested iteration. Ideally, the students should design this program from scratch. They should think about a problem to be solved, describe it as an algorithm, and select the appropriate iteration structure. It is important to emphasize that the workload must be shared and each individual must make a contribution to the project within each group. Have students document an iterative design process: start with a general idea, break it into subparts, try it out, redesign, change and refine until you have explored a variety of creative options. The reflection journal at the end will comment on the group dynamics and problem solving used to create a positive group work environment.

Wrap Up (5 min)

Journal: In your journal, summarize the process that you used with your classmates to create the collaborative project. What was your original plan or algorithm? How did you use selection and iteration? What problems did you encounter? How did each group member contribute? What was the quality of the group dynamics? What concepts need to be clarified? How would these programs be changed if they were for widespread distribution rather than for personal use?

 


Options for Differentiated Instruction

  • Give students a copy of the guided activity instructions so they can follow along.
  • Possibly give students a code stem to work from for the collaborative project (while ensuring that they have the opportunity to problem-solve by thinking about and implementing an appropriate loop structure).

Evidence of Learning

Formative Assessment

Various checking-for-understanding techniques:

  • Temperature checks
  • Teacher reviews of student's code
  • Thumbs up/ thumbs down
  • Questioning throughout the lesson (whole group / small group / individual)

Quick quizzes

Peer review

Interactive journaling


Summative Assessment

Students will work collaboratively to develop a program that uses nested iteration and turtle graphics.

Lesson Summary

Summary

In Python, a function is a named sequence of statements that belong together. In this lesson, students learn why functions are used, how they are used, and how they are defined.  

Outcomes

  • Students learn how functions affect program flow, how functions use local variables, and how they use global variables.  
  • Students learn preferred means of communication with functions and how to incorporate them into their programs.  Attention is also given to debugging programs that contain functions.

Overview

  1. Getting Started (5 min)
  2. Guided Activities (35 min)
    1. Arguments and return values [5 min]
    2. Compound Functions [5 min]
    3. Function Definitions [5 min]
    4. Return Values [10 min]
    5. Line Numbers [10 min]
  3. Wrap Up (10 min)

Source

Students will work extensively with the online version of How to Think Like a Computer Scientist (HTLACS) hosted by Runestone Interactive. 

Learning Objectives

CSP Objectives

Big Idea - Creativity
  • EU 1.2 - Computing enables people to use creative development processes to create computational artifacts for creative expression or to solve a problem.
    • LO 1.2.3 - Create a new computational artifact by combining or modifying existing artifacts. [P2]
      • EK 1.2.3A - Creating computational artifacts can be done by combining and modifying existing artifacts or by creating new artifacts.
      • EK 1.2.3B - Computation facilitates the creation and modification of computational artifacts with enhanced detail and precision.
Big Idea - Abstraction
  • EU 2.2 - Multiple levels of abstraction are used to write programs or create other computational artifacts.
    • LO 2.2.1 - Develop an abstraction when writing a program or creating other computational artifacts. [P2]
      • EK 2.2.1A - The process of developing an abstraction involves removing detail and generalizing functionality.
      • EK 2.2.1C - An abstraction generalizes functionality with input parameters that allow software reuse.
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.2 - Develop a correct program to solve problems. [P2]
      • EK 5.1.2B - Developing correct program components and then combining them helps in creating correct programs.
      • EK 5.1.2C - Incrementally adding tested program segments to correct working programs helps create large correct programs.
      • EK 5.1.2J - A programmer designs, implements, tests, debugs, and maintains programs when solving problems.
  • EU 5.3 - Programming is facilitated by appropriate abstractions.
    • LO 5.3.1 - Use abstraction to manage complexity in programs. [P3]
      • EK 5.3.1A - Procedures are reusable programming abstractions.
      • EK 5.3.1B - A procedure is a named grouping of programming instructions.
      • EK 5.3.1C - Procedures reduce the complexity of writing and maintaining programs.
      • EK 5.3.1D - Procedures have names and may have parameters and return values.
      • EK 5.3.1E - Parameterization can generalize a specific solution.
      • EK 5.3.1F - Parameters generalize a solution by allowing a procedure to be used instead of duplicated code.
      • EK 5.3.1G - Parameters provide different values as input to procedures when they are called in a program.
      • EK 5.3.1M - Application program interfaces (APIs) and libraries simplify complex programming tasks.
      • EK 5.3.1N - Documentation for an API/library is an important aspect of programming.
      • EK 5.3.1O - APIs connect software components, allowing them to communicate.
  • EU 5.4 - Programs are developed, maintained, and used by people for different purposes.
    • LO 5.4.1 - Evaluate the correctness of a program. [P4]
      • EK 5.4.1A - Program style can affect the determination of program correctness.
      • EK 5.4.1B - Duplicated code can make it harder to reason about a program.
      • EK 5.4.1C - Meaningful names for variables and procedures help people better understand programs.
      • EK 5.4.1D - Longer code segments are harder to reason about than shorter code segments in a program.
      • EK 5.4.1E - Locating and correcting errors in a program is called debugging the program.
      • EK 5.4.1G - Examples of intended behavior on specific inputs help people understand what a program is supposed to do.
  • EU 5.5 - Programming uses mathematical and logical concepts.
    • LO 5.5.1 - Employ appropriate mathematical and logical concepts in programming. [P1]

Math Common Core Practice:

  • MP1: Make sense of problems and persevere in solving them.
  • MP5: Use appropriate tools strategically.

Common Core Math:

  • F-IF.1-3: Understand the concept of a function and use function notation
  • F-IF.4-6: Interpret functions that arise in applications in terms of the context
  • F-BF.3-5: Build new functions from existing functions

Common Core ELA:

  • RST 12.4 - Determine the meaning of symbols, key terms, and other domain-specific words and phrases
  • RST 12.10 - Read and comprehend science/technical texts

NGSS Practices:

  • 5. Using mathematics and computational thinking

Key Concepts

Students will understand the purpose of functions and how they allow a program to be built and maintained in a modular way.

Predictable Misunderstandings:

- students often think that functions (or any code) written will run.  They don't connect that it must be called in order to be run.

- students often think that functions have access to variables that they don't have access.


Essential Questions

  • How can computing and the use of computational tools foster creative expression?
  • How does abstraction help us in writing programs, creating computational artifacts and solving problems?
  • How are algorithms implemented and executed on computers and computational devices?
  • How are programs developed to help people, organizations or society solve problems?
  • How are programs used for creative expression, to satisfy personal curiosity or to create new knowledge?
  • How do computer programs implement algorithms?
  • How does abstraction make the development of computer programs possible?
  • How do people develop and test computer programs?
  • Which mathematical and logical concepts are fundamental to computer programming?
  • How does computing enable innovation?

Teacher Resources

Lesson Plan

Getting Started (5 min)

  1. Show first 3:30 of Function Video: http://interactivepython.org/runestone/static/thinkcspy/Functions/functions.html
  2. Students respond in their journals to the following prompts.
  • What is a function?
  • What is a parameter?
  • What are two types of parameters?

Guided Activities (35 min)

Arguments and return values [5 min]

  • Students read Python for Everybody  Chapter 4 Functions sections 4.1 to 4.3.  
  • Students copy the sentences below.  Replace the words argument and result with synonyms.
    • “It is common to say that a function "takes" an argument and "returns" a result. The result is called the return value.” 
  • Visit this web page (https://docs.python.org/2/library/functions.html) that lists the built in functions in Python.   
  • Verify that the Python Version is 2.7.
  • Ask, "How many built in functions are in Python 2.7?"
  • Change the Python version to 3.4.1.  How many built-in functions are in Python 3.4.1?
  • Why do you think there are a different number of functions in Python 3.4.1 than in 2.7?

Compound Functions [5 min]

  • Open Runestone Interactive Functions page (http://interactivepython.org/runestone/static/thinkcspy/Functions/functions.html) and read about user defined functions in Python.
  • Read through lines 1 and 2 that define the header and body of compound statements.  Note the format of the compound statement used to define a function.
  • Ask:
    • What color is used to highlight the keyword def?
    • What punctuation mark ends the first( header) line?
    • How far is the body indented?
    • What color is the name of the function?
    • What word is used for the value in parenthesis?

Function Definitions [5 min]

  • Run ActiveCode 1.  
  • Change the number in line 15 and run the code to make a smaller square.
  • Change the number in line 15 and run the code to make a larger square.
  • Run ActiveCode 2.
  • Ask: What are the two line numbers used to call or invoke the function drawSquare?
  • Run ActiveCode 3.
  • Change the definition of drawMulticolorSquare to different colors.
  • Ask: What line would you change to draw smaller multi-color squares?

Return Values [10 min]

  • Some functions find and return values.  Complete ActiveCode 5, 6 and 7.
  • Change ActiveCode 7 so it prints the minimum values.

Line Numbers [10 min]

  • Run CodeLens 1.
  • Ask:
    • What line is executed next after line 6?
    • What line is executed next after line 3?
    • How do you think Python knew what line to go to after line 3?
    • What keyword is used to tell Python to return a value from the function named square?
    • What do you think would happen if you run the program after removing the return statement from line 3?

Wrap Up (10 min)

  • Return to Python for Everybody Chapter 4 Functions  Copy and paste the code from section 4.4 to Runestone ActiveCode 4.
  • Run the code multiple times.
  • Ask:
    • What do you note about the results?
    • What is the name of the function used?
    • Is the function on the list of the built-in Python functions or is it defined in the program?
    • Where do you think the function is defined?
  • Add the number 1 as a parameter in the function call and run the program.
  • Explain the error message.
  • Write one thing to remember about functions on an exit note.

Homework:  Students should read Python for Everybody Chapter 4: Sections 4.7, 4.8 and 4.9.  Complete Exercises 2 and 3.  

Answer the following questions:

  •  What error message occured in Exercise 3?
  •  Why did the error occur?
  •  What happened when you change the order of print_lyrics and repeat_lyrics function definitions in Exercise 3?
  •  How is a function call like a road detour?
  • The parameter used to define the function print_twice is named bruce.  How would the function behavior change if the name was changed to wayne all three times it appears in the function definition?

Options for Differentiated Instruction

Students should be paired through this exercise since paired discussion is used for formative assessment.  Question can be provided to students through a variety of formats including production of a Google form or using student response systems.

Three suggested strategies are:

  • provide guide questions for reading
  • provide teacher provided annotated text excerpts
  • Students annotate text while reading

 

 


Evidence of Learning

Formative Assessment

After Activity D, have students compare results with their elbow partners.  Discuss any unresolved issues.  This strategy can be used after any check for understanding.

After Activity F, ask students to suggest a rule for creating functions that would help avoid this error.

Students work alternately between the web site, partners, and the whole group.  Teachers are to monitor student responses to the questions following each activity to be sure that students are addressing the key content within each activity.


Summative Assessment

  • Explain the advantages of functions/procedures in programming.
  • Explain the purpose of parameters with the use of functions.
  • Define a Python function with and without parameters.
  • Call a Python function with and without parameters.
  • Trace a function call from the main program to and from a user defined function.
  • Modify a Python program to use a function.
  • Create and use functions that return a string or a number.

Lesson Summary

Summary

This is the third session of a three-session lesson sequence with four topics covered by mini-lectures, explorations, and practice exercises.

Outcomes

  • Students will translate sample pseudocode into a Python function.
  • Students will recognize layers of abstraction for solving a Rubik's cube.
  • Students will identify sequencing, selection, and iteration elements in a problem solution.

Overview

  1. Getting Started (5 min)
  2. Activities (40 min)
    1. Guided Activity 1 [20 min]
    2. [Optional] Mini-Lecture 1 [20 min]
    3. [Optional] Guided Activity 2 [20 min]
    4. Mini-Lecture 2 [20 min]
  3. 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.1 - Develop an abstraction when writing a program or creating other computational artifacts. [P2]
      • EK 2.2.1A - The process of developing an abstraction involves removing detail and generalizing functionality.
      • EK 2.2.1B - An abstraction extracts common features from specific examples in order to generalize concepts.
      • EK 2.2.1C - An abstraction generalizes functionality with input parameters that allow software reuse.
    • LO 2.2.2 - Use multiple levels of abstraction to write programs. [P3]
      • EK 2.2.2A - Software is developed using multiple levels of abstractions, such as constants, expressions, statements, procedures, and libraries.
    • 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.
Big Idea - Algorithms
  • EU 4.1 - Algorithms are precise sequences of instructions for processes that can be executed by a computer and are implemented using programming languages.
    • LO 4.1.1 - Develop an algorithm for implementation in a program. [P2]
      • EK 4.1.1A - Sequencing, selection, and iteration are building blocks of algorithms.
      • EK 4.1.1B - Sequencing is the application of each step of an algorithm in the order in which the statements are given.
      • EK 4.1.1C - Selection uses a Boolean condition to determine which of two parts of an algorithm is used.
      • EK 4.1.1D - Iteration is the repetition of part of an algorithm until a condition is met or for a specified number of times.
      • EK 4.1.1E - Algorithms can be combined to make new algorithms.
      • EK 4.1.1G - Knowledge of standard algorithms can help in constructing new algorithms.
      • EK 4.1.1H - Different algorithms can be developed to solve the same problem.
      • EK 4.1.1I - Developing a new algorithm to solve a problem can yield insight into the problem.
    • LO 4.1.2 - Express an algorithm in a language. [P5]
      • EK 4.1.2A - Languages for algorithms include natural language, pseudocode, and visual and textual programming languages.
      • EK 4.1.2B - Natural language and pseudocode describe algorithms so that humans can understand them.
      • EK 4.1.2C - Algorithms described in programming languages can be executed on a computer.
      • EK 4.1.2G - Every algorithm can be constructed using only sequencing, selection, and iteration.
      • EK 4.1.2I - Clarity and readability are important considerations when expressing an algorithm in a language.
Big Idea - Programming
  • EU 5.2 - People write programs to execute algorithms.
    • LO 5.2.1 - Explain how programs implement algorithms. [P3]
      • EK 5.2.1A - Algorithms are implemented using program instructions that are processed during program execution.
      • EK 5.2.1B - Program instructions are executed sequentially.
      • EK 5.2.1C - Program instructions may involve variables that are initialized and updated, read, and written.
      • EK 5.2.1D - An understanding of instruction processing and program execution is useful for programming.

Math Common Core Practice:

  • MP1: Make sense of problems and persevere in solving them.
  • MP2: Reason abstractly and quantitatively.
  • MP7: Look for and make use of structure.

Common Core Math:

  • G-CO.6-8: Understand congruence in terms of rigid motions
  • G-GMD.4: Visualize relationships between two-dimensional and three-dimensional objects

Common Core ELA:

  • RST 12.3 - Precisely follow a complex multistep procedure
  • RST 12.8 - Evaluate the hypotheses, data, analysis, and conclusions in a science or technical text
  • WHST 12.4 - Produce clear and coherent writing in which the development, organization, and style are appropriate to task, purpose, and audience

NGSS Practices:

  • 2. Developing and using models
  • 5. Using mathematics and computational thinking
  • 6. Constructing explanations (for science) and designing solutions (engineering)

NGSS Content:

  • HS-ETS1-2. Design a solution to a complex real-world problem by breaking it down into smaller, more manageable problems that can be solved through engineering.

Key Concepts

An algorithm is more than just a sequence of steps: levels of abstraction are crucial to the working of algorithms, and sequencing, iteration, and other control structures are ubiquitous.


Essential Questions

  • How does abstraction help us in writing programs, creating computational artifacts and solving problems?
  • How are algorithms implemented and executed on computers and computational devices?
  • How do computer programs implement algorithms?

Teacher Resources

Student computer usage for this lesson is: optional

In Lesson Resources folder:

  • AlgorithmsPseudocode3.pptx : PowerPoint Slides for mini-lectures
  • ConwayDoomsdayAlgorithm : file for "Day of the Week" algorithm, Conway's "Doomsday"

[Optional topic] Wikipedia article on Conway date algorithm.

Access to Youtube videos of people and Lego Robots solving Rubik's cubes.

Videos:

  •     CUBESTORMER 3 Smashes Rubik's Cube Speed Record by ARMflix 

https://www.youtube.com/watch?v=X0pFZG7j5cE and /or

  • CUBESTORMER 2 by ARMflix

https://www.youtube.com/watch?v=_d0LfkIut2M

  • Human World Record: Kopie Van Mats Valk Official Rubik's Cube Single 5:55 by Mats Valk

https://www.youtube.com/watch?v=UXrxRqwAUkA 

One or more Rubik's cubes.

Links to PDF copies of youcandothecube's solution to Rubik's cube (also copied into the Lesson Resources folder):

      You Can Do the Rubik's Cube

Lesson Plan

Getting Started (5 min)

Daily Homework Review

  • Review of pseudocode for determining if a year is a Leap Year 

Guided Activities (40 min)

  • Guided Activity 1
    • Discuss how abstraction involves removing detail and lets you describe things in a general way. Problems can be broken down from very general steps down to specific details. One way to do this is to extract common features from specific examples in order to generalize concepts. Look for this in the Leap Year code.
    • Demonstrate Python function implementation for the "Is it a Leap Year" pseudocode.
  • [Optional] Mini-lecture 1
    • Teach Conway "Day of the Week" algorithm. Use the file called ConwayDoosmdayAlgorithm in the Lesson Resources folder.
  • [Optional] Guided Activity 2
    • Have students practice the Conway algorithm.

Wrap Up (5 min)

  • Review Table of Contents of selected Algorithms book.
  • Review summary slide.
  • Homework: Take one of the youcandothecube.com solution stages.  Identify the sequencing, selection, and iteration elements.  Sketch a flowchart of that stage of the solution.

Options for Differentiated Instruction

For the optional activity (Conway Algorithm), some students may have difficulty adding and subtracting dates to translate from a known day-of-the-week to another day in the same month.  A chart on the wall, or a current calendar, could be a help.

Some students who are strong in other areas will have difficulty with the spatial aspects of manipulating a cube while retaining an orientation that will let them complete the steps of one of the sub-algorithms without errors.  They may need to be paired with another student or the instructor until they master the technique of holding the cube fixed while rotating a face.

The notation of face turning (e.g. R versus R' or L versus L') can be confusing.  Having the students practice with an empty jar with a lid can help.  Orient the lid up (U), down (D), left (L), right (R), front (F), or back (B).  The hand movement to screw the lid on is the same hand movement needed to perform the non-accented face turn.  The hand movement needed to screw the lid off is the same as the accented turn (U', D', L', R', F', B').

Variation for class that does not have Rubik's cubes:  Use the images from the Solution Guide: www.youcandothecube.com

Online rubik's cube solver:


Evidence of Learning

Formative Assessment

The following "Checks for Understanding" could be used to guide the students towards the three learning objectives.

Objective: SWBAT translate sample pseudocode into a Python function.

  1. Word Sort.  Students will evaluate isolated Python constructs as matching sequencing, selection, or iteration elements.
  2. Timed Pair Share.  Pairs of students will translate the challange examples from pseudocode into Python.
  3. Project Study Group.  Looking at pseudocode and non-working Python code:  What is wrong?  What is missing?  How would you change it?

Objective: SWBAT recognize layers of abstraction for solving a Rubik's cube.

  1. Describe it.  Students will first study and then will identify characteristics of Rubik's cubes (number of sides; possible movements; number and types of pieces -- center, edge, corner; ...)
  2. Predict and share -- students will predict strategies for solving the cube.
  3. Put in order -- groups of students will take a set of partially solved cubes and place them in "solution order".  They will justify their choice.  [Note: images from www.youcandothecube.com can be used if real cubes are not available.]
  4. Learn one layer.  Every student will learn how to execute one full step of the solution sequence.

SWBAT to identify sequencing, selection, and iteration elements in a problem solution.

  1. Students will identify the sequencing, selection, and iteration steps of: their homework algorithm; two of the sample problems from the challenge set; and one of the stages of the Rubric cube solution.  These will be done in pairs and small groups.

Summative Assessment

Students will translate prior pseudocode into Python routines.  They will recognize if their programs work correctly.

Students will deconstruct one of the Rubik's cube solution stages.  These analysis results will be shared and critiqued.

Lesson Summary

Summary

In the first portion of this lesson, students continue their inquiry into the properties of functions, with a focus on communication to and from other functions. In the lab portion of the lesson, students develop three Python modules using both Runestone Interactive and their Python IDE. Students use their own functions to perform calculations and draw a variety of polygons and a circle using turtle graphics.

Outcomes

  • Students will understand the process of communication with functions.
  • Students will be able to create and call functions.
  • Students will be able to use both "fruitful functions" (sometimes just called functions) and "unfruitful functions" (which do not return a value - these are usually called procedures).
  • Students will understand how functions simplify a project's creation.

Overview

Session 1

  1. Warmup (10 min)
  2. Exploring Functions (40 min)

Session 2

  1. Function Labs (45 min)
  2. Wrap-up (5 min)

Learning Objectives

CSP Objectives

Big Idea - Creativity
  • EU 1.1 - Creative development can be an essential process for creating computational artifacts.
    • LO 1.1.1 - Apply a creative development process when creating computational artifacts. [P2]
      • EK 1.1.1A - A creative process in the development of a computational artifact can include, but is not limited to, employing nontraditional, nonprescribed techniques; the use of novel combinations of artifacts, tools, and techniques; and the exploration of personal curiosities.
      • EK 1.1.1B - Creating computational artifacts employs an iterative and often exploratory process to translate ideas into tangible form.
  • EU 1.2 - Computing enables people to use creative development processes to create computational artifacts for creative expression or to solve a problem.
    • LO 1.2.2 - Create a computational artifact using computing tools and techniques to solve a problem. [P2]
      • EK 1.2.2A - Computing tools and techniques can enhance the process of finding a solution to a problem.
    • LO 1.2.3 - Create a new computational artifact by combining or modifying existing artifacts. [P2]
      • EK 1.2.3A - Creating computational artifacts can be done by combining and modifying existing artifacts or by creating new artifacts.
      • EK 1.2.3B - Computation facilitates the creation and modification of computational artifacts with enhanced detail and precision.
    • LO 1.2.4 - Collaborate in the creation of computational artifacts. [P6]
      • EK 1.2.4A - A collaboratively created computational artifact reflects effort by more than one person.
      • EK 1.2.4C - Effective collaborative teams practice interpersonal communication, consensus building, conflict resolution, and negotiation.
      • EK 1.2.4D - Effective collaboration strategies enhance performance.
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.2 - Develop a correct program to solve problems. [P2]
      • EK 5.1.2A - An iterative process of program development helps in developing a correct program to solve problems.
      • EK 5.1.2B - Developing correct program components and then combining them helps in creating correct programs.
      • EK 5.1.2C - Incrementally adding tested program segments to correct working programs helps create large correct programs.
      • EK 5.1.2H - Consultation and communication with program users is an important aspect of program development to solve problems.
      • EK 5.1.2J - A programmer designs, implements, tests, debugs, and maintains programs when solving problems.
    • LO 5.1.3 - Collaborate to develop a program. [P6]
      • EK 5.1.3A - Collaboration can decrease the size and complexity of tasks required of individual programmers.
      • EK 5.1.3E - Collaboration facilitates developing program components independently.
      • EK 5.1.3F - Effective communication between participants is required for successful collaboration when developing programs.
  • EU 5.3 - Programming is facilitated by appropriate abstractions.
    • LO 5.3.1 - Use abstraction to manage complexity in programs. [P3]
      • EK 5.3.1A - Procedures are reusable programming abstractions.
      • EK 5.3.1B - A procedure is a named grouping of programming instructions.
      • EK 5.3.1C - Procedures reduce the complexity of writing and maintaining programs.
      • EK 5.3.1D - Procedures have names and may have parameters and return values.
      • EK 5.3.1E - Parameterization can generalize a specific solution.
      • EK 5.3.1F - Parameters generalize a solution by allowing a procedure to be used instead of duplicated code.
      • EK 5.3.1G - Parameters provide different values as input to procedures when they are called in a program.
      • EK 5.3.1M - Application program interfaces (APIs) and libraries simplify complex programming tasks.

Math Common Core Practice:

  • MP4: Model with mathematics.
  • MP5: Use appropriate tools strategically.

Common Core ELA:

  • RST 12.2 - Determine central ideas and conclusions in the text
  • RST 12.3 - Precisely follow a complex multistep procedure
  • RST 12.4 - Determine the meaning of symbols, key terms, and other domain-specific words and phrases
  • RST 12.10 - Read and comprehend science/technical texts

NGSS Practices:

  • 1. Asking questions (for science) and defining problems (for engineering)
  • 5. Using mathematics and computational thinking

Key Concepts

  • Students will understand the process of communication with functions.
  • Students will be able to create and call functions.
  • Students will be able to use both fruitful and unfruitful functions.
  • Students will understand how functions simplify a project's creation.
  • Students will work collaboratively in pairs to enhance performance and communication

Essential Questions

  • How does abstraction help us in writing programs, creating computational artifacts and solving problems?
  • How are algorithms implemented and executed on computers and computational devices?
  • How are programs developed to help people, organizations or society solve problems?
  • How do computer programs implement algorithms?
  • How does abstraction make the development of computer programs possible?
  • How do people develop and test computer programs?

Teacher Resources

Student computer usage for this lesson is: required

Lesson Plan

Session 1

Getting Started (10 min)

  • Display Python for Everybody Chapter 4 (Functions) - Section 4.11.
  • Students record in their journals four reasons to use functions and discuss with elbow partners to identify their two most important reasons.
  • Ask students to identify two or three people they know who have the same name.
    • Explain to their elbow partners who the people are and how they tell them apart when talking about them.
    • Explain that we are going to working with functions today and that sometimes functions use the same names for different variables.
    • Before writing programs with functions, we want to address the possibility of functions that use the same names.

Exploring Functions (40 min)

Teaching Note: 

Use of a format such as Google forms is sugggested for collecting student responses to the questions for each activity. It is important to keep this portion of the class moving so students have enough time for the labs. Have students work with partners during their program development so they will have someone to share their progress with. Use a timer and have students briefly share their progress roughly every 10 minutes. This will not only help them understand an iterative development process, but also gives students practice with a collaborative development style.

Debugging

  • Display Section 4.12 of Python for Everybody.  
  • Explain: when progam developers write their own functions, they often run into problems (bugs) they need to fix. These debugging suggestions should help the students to prevent or correct problems.
  • As students investigate and work with functions today, they should an eye out for function design problems and strategies used to prevent or solve them. We will add the rules we develop to this list. 

Variables and Parameters

  • Students should open the Runestone Interactive Functions page (http://interactivepython.org/runestone/static/thinkcspy/Functions/toctree.html).
  • Have students read "Variables and parameters are local" and run the Codelens to completion.  
  • Ask:
    • What caused the error that occurred when the last line of the code was executed?
    • What happens to local variables when a function finishes?
    • Are parameter's values that are assigned inside a function also accessible outside the function? 

Global Variables (Don't Use Them!)

  • Run ActiveCode 9.
  • What is the value of the variable power inside the function?
  • At what point was the variable power given that value?
  • This form of communication is risky, since programmers may not realize that a variable used in one code segment is also used inside a function elsewhere in the program.  
  • What is the recommended way to communicate values to a variable?
  • Emphasize that avoiding global variables supports collaboration and reuse of code, since different authors can avoid interfering with each other's work.

Variable Scope

  • Complete the "Check for Understanding" after CodeLens 5, answering questions func-10, func-11, and func-12.
  • Share "Check for Understanding" results either with elbow partners or the class as a whole. 

Accumulating Values

  • Go to the section entitled "The accumulator pattern."
  • Do ActiveCode 10 and CodeLens 6.
  • After reviewing the execution in the CodeLens, answer the "Check for Understanding" questions func-13 through func-14.
  • See if the students can add any rules for creating and using functions to the list from Python for Informatics.

Functional Decomposition

  • Go to the section entitled "Functions can call other functions".
  • Do CodeLens 7 and ActiveCode 12.
  • Ask:  
    • What function is started first when the code in ActiveCode 12 is executed?
    • What function is finished first when the code is executed?

Session 2

Function Labs (45 min)

  • Review concepts from Session 1. Reinforce pair programming dynamics of navigator /driver, changing roles and communication goals to resolve any conflicts, and allow everyone to participate.
  • Encourage students to refer to the API to better understand how functions work. (Remind them that every high level programming language provides an API (Applicaiton Program Interface) that explains the functions available and how to use them.
  • Preview the three lab projects that students will complete and help students to get started with the Slope Y-Intercept project.
  • Complete the Slope Y-Intercept Project and the Drawing a Circle Labs.
    • The Slope Y-Intercept Project is described in the document of the same name.
    • The document includes descriptions of two functions to complete and contains a small sample of test data.
    • The Slope Y-Intercept Project is in the Lesson Resources folder along with the starter Python file.
  • Continue in Runestone to the Lab entitled Drawing a Circle (http://interactivepython.org/runestone/static/thinkcspy/Labs/lab04_01.html).
    • In this second lab, students develop a function that uses a turtle to draw a circle.
    • After finishing the lab, students should copy their code to a Python module in PyCharm.
    • Students should create three functions named drawSquare, drawTriangle, and drawOctagon, along with main module code that calls each function.
  • After completing the Drawing a Circle lab, students should follow the link below to the Lessons from a Triangle lab.
  • Students should create a second Python module with the code from the starting point for the drawPolygon function code and finish implementing the drawPolygon function.
  • Students should complete the Function Labs by developing the drawCircle function in Finally a Circle (the second half of the Lessons from a Triangle lab).
    • Additional components of the lab can be used as extensions for more able students.

Wrap-Up (5 minutes)

  • After submitting the labs, students present their labs with elbow partners and groups.
  • Students reflect on the following prompts about writing programs with functions.
  • What problems did they encounter? (with concepts or partner dynamics)
  • How did they overcome the problems? How was the API useful?
  • How do functions simplify the task of developing a program?
  • How can effective collaboration enhance performance?

Options for Differentiated Instruction

Iterative development works by developing, then sharing, programs at many points during the development process. Students should work in pairs as they create their programs and share the work through various completion stages.

Students who are completing projects quickly should be introduced to the Python turtle API at (https://docs.python.org/3.4/library/turtle.html). Students can investigate and implement such methods as fill, speed and others as described by the API documentation.  


Evidence of Learning

Formative Assessment

Check for understanding by assessing student performance on the Runestone Interactive questions. Students should first try to resolve any difficulties with their partners and groups.

Students should be able to make suggestions for creating and using functions.

Identify and address any areas discovered that students have been unable to come to a consensus understanding. 

Have students reflect on the pair programming process as prompted in the lesson.


Summative Assessment

Create functions that receive parameters, perform calculations using those parameters, and return a value.

Write a function to return the slope and y-intercept of a function of the line through two points.

Write functions to create a variety of polygons and a circle.

Lesson Summary

Summary

Students will use the online book Python for Everybody to complete a two-session guided lab in which they will explore the use of strings in Python.

Outcomes

Students will be able to:

  • Identify a string as a sequence of characters that are identified by their index value, beginning with 0 (zero)
  • Use the len function to get the number of characters in a string
  • Traverse strings using both while and for loops
  • Slice strings using [m:n]
  • Parse strings using the find method and slicing
  • Debug simple string programs to find and correct problems

Overview

Session 1:

  1. Getting Started (5 min)
  2. Guided Activity (45 min)
    1. Preparation [5 min]
    2. Code Review [40 min]

Session 2:

  1. Getting Started (5 min)
  2. Guided Activity (35 min)
    1. Preparation [5 min]
    2. Code Review [30 min]
  3. Summative Assessment (10 min)

Learning Objectives

CSP Objectives

Big Idea - Creativity
  • EU 1.2 - Computing enables people to use creative development processes to create computational artifacts for creative expression or to solve a problem.
    • LO 1.2.2 - Create a computational artifact using computing tools and techniques to solve a problem. [P2]
      • EK 1.2.2A - Computing tools and techniques can enhance the process of finding a solution to a problem.
Big Idea - Algorithms
  • EU 4.1 - Algorithms are precise sequences of instructions for processes that can be executed by a computer and are implemented using programming languages.
    • LO 4.1.1 - Develop an algorithm for implementation in a program. [P2]
      • EK 4.1.1A - Sequencing, selection, and iteration are building blocks of algorithms.
      • EK 4.1.1B - Sequencing is the application of each step of an algorithm in the order in which the statements are given.
      • EK 4.1.1C - Selection uses a Boolean condition to determine which of two parts of an algorithm is used.
      • EK 4.1.1D - Iteration is the repetition of part of an algorithm until a condition is met or for a specified number of times.
      • EK 4.1.1H - Different algorithms can be developed to solve the same problem.
      • EK 4.1.1I - Developing a new algorithm to solve a problem can yield insight into the problem.
    • LO 4.1.2 - Express an algorithm in a language. [P5]
      • EK 4.1.2A - Languages for algorithms include natural language, pseudocode, and visual and textual programming languages.
      • EK 4.1.2C - Algorithms described in programming languages can be executed on a computer.
      • EK 4.1.2G - Every algorithm can be constructed using only sequencing, selection, and iteration.
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.2 - Develop a correct program to solve problems. [P2]
      • EK 5.1.2A - An iterative process of program development helps in developing a correct program to solve problems.
      • EK 5.1.2B - Developing correct program components and then combining them helps in creating correct programs.
      • EK 5.1.2C - Incrementally adding tested program segments to correct working programs helps create large correct programs.
      • EK 5.1.2I - A programmer's knowledge and skill affects how a program is developed and how it is used to solve a problem.
      • EK 5.1.2J - A programmer designs, implements, tests, debugs, and maintains programs when solving problems.
  • EU 5.2 - People write programs to execute algorithms.
    • LO 5.2.1 - Explain how programs implement algorithms. [P3]
      • EK 5.2.1A - Algorithms are implemented using program instructions that are processed during program execution.
      • EK 5.2.1B - Program instructions are executed sequentially.
      • EK 5.2.1C - Program instructions may involve variables that are initialized and updated, read, and written.
      • EK 5.2.1D - An understanding of instruction processing and program execution is useful for programming.
  • 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.
  • EU 5.4 - Programs are developed, maintained, and used by people for different purposes.
    • LO 5.4.1 - Evaluate the correctness of a program. [P4]
      • EK 5.4.1C - Meaningful names for variables and procedures help people better understand programs.
      • EK 5.4.1E - Locating and correcting errors in a program is called debugging the program.
      • EK 5.4.1F - Knowledge of what a program is supposed to do is required in order to find most program errors.
      • EK 5.4.1G - Examples of intended behavior on specific inputs help people understand what a program is supposed to do.
      • EK 5.4.1H - Visual displays (or different modalities) of program state can help in finding errors.
      • EK 5.4.1K - Correctness of a program depends on correctness of program components, including code segments and procedures.
  • 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.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.
      • EK 5.5.1G - Intuitive and formal reasoning about program components using Boolean concepts helps in developing correct programs.

Math Common Core Practice:

  • 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.10 - Read and comprehend science/technical texts

NGSS Practices:

  • 5. Using mathematics and computational thinking

Key Concepts

  • Strings are made up of individual characters in a sequence.  The characters are identified by their position in the string; this position is referred to as an index value.
  • Index values in Python begin with zero (0).
  • Python provides a number of built-in functions and methods that allow a programmer to manipulate strings.  
  • Strings can be traversed using both for and while loops. Students must decide which loop structure is appropriate, based on the nature of a program's requirements.

Essential Questions

  • How can computing and the use of computational tools foster creative expression?
  • How are algorithms implemented and executed on computers and computational devices?
  • How are programs used for creative expression, to satisfy personal curiosity or to create new knowledge?
  • How do computer programs implement algorithms?
  • How do people develop and test computer programs?
  • Which mathematical and logical concepts are fundamental to computer programming?

Teacher Resources

Student computer usage for this lesson is: required

In the Lesson Resources folder:

  • Python for Everybody by Charles Severance, http://do1.dr-chuck.com/pythonlearn/EN_us/pythonlearn.pdf.
    This book is available for download as a .pdf file. We recommend downloading the book and making it available on a shared group drive on local computers for easy access for students. Is it licensed under Creative Commons and is free to download and share.  A copy of the pdf is available in the Lesson Resources folder.

Other:

Lesson Plan

Session 1

Getting Started (5 min)

Journal Question: What is a string?

  • Have students share their ideas.

Guided Activity (45 min)

Preparation [5 min]

  • Students should open the book Python for Everybody by Charles Severance, Chapter 6: Strings (page 67). (Available at http://do1.dr-chuck.com/pythonlearn/EN_us/pythonlearn.pdf and in the lesson folder.)
  • Students should launch PyCharm and make a new file called stringtester.py to test code as they go though the lesson.
  • Recommend teachers project their screens with the book and PyCharm environment when appropriate.
  • Have students test code samples from the book as the students and teacher go through the lesson together.

Code Review [40 min]

Section 6.1: A string is a sequence

  • Introduce the concept of index values for each character in a string, beginning with 0 (zero).
  • After reading the brief text in Section 6.1, have students type the sample code for fruit and letter with [ ] surrounding the index value of a letter and run it. Have students try to ‘break’ the code by typing in an index value too large for the word and see what kind of error they get.
  • Code check for understanding: have students type in a different word for their fruit variable and change the index value. Does the printed letter match what was anticipated?
  • Concept check for understanding: reinforce understanding by writing sample words on board, pointing to a letter at random and asking what the index value of that letter.
  • Repeat checks for understanding with made-up problems as needed.

Section 6.2: Getting the length of a string using len

  • Introduce the len function, which returns the number of characters in a string. Explain that empty spaces between words and punctuation also count as characters. Remind students of previous lessons concerning ASCII values for all characters, including blank spaces and punctuation.
  • Using the fruit variable from the previous sample, have students return the number of characters using the len function.
  • Stress the point in the book concerning IndexErrors: that the length of the string and the highest index value in that same string are not the same value. The length of the string banana is 6; the index values are numbered from 0 to 5, inclusive.
  • Code check for understanding: Have students type in sample code that will return the length of a variety of strings, with and without spaces and punctuation. Did their code run without error?
  • Concept check for understanding: Write a sentence on the board with spaces and punctuation. Have students count and write the “length” of the sentence on a post-it note and stick them on a designated place. Have a student or two organize the post-its based on the answers. Together with the class, count out the value of len, then have students type the sentence into the console in PyCharm to check their answers.
  • Repeat checks for understanding with made-up problems as needed. Some famous quotes can be used to keep it interesting, such as, "The artist is nothing without the gift, but the gift is nothing without work." - Emile Zola (1840-1902). 

Section 6.3: Traversal through a string with a loop

  • Introduce the concept of printing each character of a string on a separate line by using a while loop and incrementing the index value of each character.
  • Students should already be familiar with iteration using both while and for loops from previous lessons. Review syntax for both as needed.
  • Have students traverse the string by running the sample code.

Session 2

Getting Started (5 min)

Journal Question: Explain why the length of a string is one digit higher than the highest index value of the same string.

  • Have students share their answers. Guide the discussion back to the previous lesson, in which students traversed a string with a loop.
  • Share a sample of code similar to the traversal with a while loop from the last lesson and ask students to determine the output based on an evaluation of the code.  Example:
word = "alphabet"
index = 0

while index < len(word):
letter = word[index]
print (letter)
index = index + 1
  •  Remind students of the shortcut to increment index, using index += 1 in place of index = index + 1.

Guided Activity (35 min)

Preparation [5 min]

  • Students should open the book Python for Everybody by Charles Severance, Chapter 6: Strings (page 67). (Available at http://do1.dr-chuck.com/pythonlearn/EN_us/pythonlearn.pdf and in Lesson Resources folder.)
  • Students should launch PyCharm and open the stringtester.py file used to test the code that they created during the last lesson. 

Code Review [30 min]

Section 6.3: Traversal through a string with a loop continued

  • Take students through a discussion of traversing a loop backwards by beginning at the end of the length of the string minus 1, and decrementing the loop control variable (index) instead of incrementing.
  • Code check for understanding: Book Exercise 6.1: Write a while loop that starts at the last character in the string and works its way backwards to the first character in the string, printing each letter on a separate line, except backwards.

Sample solution:

fruit = "watermelon"
length = len(fruit)
index = length - 1
while index >= 0:    letter = fruit[index]    print(letter)    index -= 1
  • Concept check for understanding: Project your code with errors and have students write the errors they find on post-it notes and stick them on a designated space. Have a student, or small group of students, organize the post-its in a way which makes sense to them. Debug the program together as a class based on the post-it note results.
  • Introduce the concept of using a for loop instead of a while loop to traverse a string.
  • Code check for understanding: Have students type sample code found at the top of page 69 in the book, using a for loop to traverse a string.
  • Concept check for understanding: Ask students to think about when it is more helpful to use a while loop than a for loop to traverse a string and share their ideas. Expect answers such as “it is easier to make a for loop” and “it is harder to move backwards through a for loop than a while loop.”
  • Explain that the word char in the example is used as a variable and is not a keyword in Python. It can be replaced with another word or letter. Have students use x instead of char in their sample for loop code to test this concept. This is an opportunity to have a discussion about using meaningful variable names so they have self-documenting code. 

Section 6.4: String slices

  • Students should return to page 69 in the book. Introduce the concept of slicing strings using the [n:m] syntax to indicate returning a string from the nth character to the mth character, not including the mth character.
  • Code checks for understanding: have students type in sample code which will slice strings in all the various ways covered in the section. For example:
print(fruit[0:3]) # returns app because a is in the 0th position and the second p is in the 2nd position.
                 # The slice goes to ‘p’ not including the ‘p’.
print(fruit[:3]) # Still returns app because a is in the 0th position.                  # Leaving the first index blank begins the slice at the beginning of the string,                  # and the second p is in the 2nd position.                  # The slice goes to ‘p’ not including the ‘p’. print(fruit[3:]) # Returns le because l is in the 3rd position.                  # Leaving the second index blank ends the slice at the end of the string. print(fruit[:]) # Returns apple because n begins at zero and m goes to the end of the string.
  • Concept check for understanding: answer the question for Exercise 6.2: Given that fruit is a string, what does fruit[:] mean?
  • Note: If you have time, you may want to go through Sections 6.5 - 6.9. Section 6.9 explains the difference between functions and methods, which will be useful when students use the find method while parsing strings.

Section 6.10: Parsing strings

  • Introduce the find method and apply slicing in this section.
  • As you go through this section, pay special attention to the find method. Explain that the find method returns the position at which the substring we are searching for begins.
  • Code check for understanding: Have students type in practice code other than what is in the book and use the find method without error.
  • Sample code:
message = 'Meet me at the clock tower @ 7:00 a.m.'
atSign = message.find('@')
print (atSign)


This code sample returns 27, indicating that the @ sign is at index value 27 in the string.

Journal: How are string functions used in everyday life? (search engines to find information quickly, school databases to look up student information, many more). How much more efficient is a computer at looking through millions of strings of data compared to a human? Extension: what if you were looking for a particular face in a crowd in a video, how could computational tools enhance that process?

Summative Assessment (10 min)

  • Coding assessment and/or quiz.  Alternatively, the assessment may be assigned as homework.

Options for Differentiated Instruction

Students can work in pairs while new concepts are introduced and practiced.

One advanced student could be assigned to be the "checker" for each row and have them raise a flag or something similar when they have checked off everybody in their row as having one small group of programming exercises complete and correct. Possibly offer a token prize to the winning row.

For example, after Section 6.3, the following exercise could be assigned:

  1. Everybody choose a different fruit. 
  2. Write code to display the first vowel in the name of the fruit and the first consonant.
  3. Display the length of the fruit.
  4. Print each character of their fruit name on a separate line by using a while loop.

Evidence of Learning

Formative Assessment

Code checks for understanding and concept checks for understanding are provided with each new function, method, or concept introduced.


Summative Assessment

Summative coding assessment:

  • Assign your first and last name to a variable.
  • Use the find method to locate the space between your first and last names.
  • Use slicing to isolate and print only your first name.

Sample answer code:

name = 'Pat Miller'
space = name.find(' ')
firstName = name[0:space]
print (firstName)

It is recommend that a 10-question multiple choice quiz that requires students to evaluate code samples from these lessons, determining the output or possible outcomes when the code is run be developed.

 

Lesson Summary

Summary

This lesson answers the question "What is a list and what can I do with one?". Students will find the answer to this question by exploring list operations and methods, as well as investigating how lists are modeled in real-world situations.

Outcomes

  • Students will create lists, access, and traverse elements within the list.
  • Students will perform list operations including insertion, concatenation, repetition, slices, and deletion.
  • Students will be introduced to list methods including append, insert, pop, sort, reverse, index, count, and remove.
  • Students will explore the Python API.
  • Students will use lists to model several real-world situations.

Overview

Session 1

  1. Getting Started (5 min)
    1. Introduction [3 min]
    2. Discussion [2 min]
  2. Guided Activities (40 min)
    1. Listy Linkys RolePlay [20 min]
    2. Python Documentation [10 min]
    3. List Slices [10 min]
  3. Wrap Up (5 min)
    1. Homework

Session 2

  1. Getting Started (5 min)
  2. Guided Activities (40 min)
    1. Lists are Mutable [20 min]
    2. Paired Programming [20 min]
  3. Wrap Up (5 min)
    1. Homework

Learning Objectives

CSP Objectives

Big Idea - Creativity
  • EU 1.2 - Computing enables people to use creative development processes to create computational artifacts for creative expression or to solve a problem.
    • LO 1.2.4 - Collaborate in the creation of computational artifacts. [P6]
      • EK 1.2.4A - A collaboratively created computational artifact reflects effort by more than one person.
  • EU 1.3 - Computing can extend traditional forms of human expression and experience.
    • LO 1.3.1 - Use computing tools and techniques for creative expression. [P2]
      • EK 1.3.1E - Computing enables creative exploration of both real and virtual phenomena.
Big Idea - Algorithms
  • EU 4.1 - Algorithms are precise sequences of instructions for processes that can be executed by a computer and are implemented using programming languages.
    • LO 4.1.1 - Develop an algorithm for implementation in a program. [P2]
      • EK 4.1.1A - Sequencing, selection, and iteration are building blocks of algorithms.
      • EK 4.1.1B - Sequencing is the application of each step of an algorithm in the order in which the statements are given.
      • EK 4.1.1C - Selection uses a Boolean condition to determine which of two parts of an algorithm is used.
      • EK 4.1.1D - Iteration is the repetition of part of an algorithm until a condition is met or for a specified number of times.
      • EK 4.1.1E - Algorithms can be combined to make new algorithms.
      • EK 4.1.1H - Different algorithms can be developed to solve the same problem.
      • EK 4.1.1I - Developing a new algorithm to solve a problem can yield insight into the problem.
    • LO 4.1.2 - Express an algorithm in a language. [P5]
      • EK 4.1.2A - Languages for algorithms include natural language, pseudocode, and visual and textual programming languages.
      • EK 4.1.2B - Natural language and pseudocode describe algorithms so that humans can understand them.
      • EK 4.1.2C - Algorithms described in programming languages can be executed on a computer.
      • EK 4.1.2G - Every algorithm can be constructed using only sequencing, selection, and iteration.
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.1 - Develop a program for creative expression, to satisfy personal curiosity, or to create new knowledge. [P2]
      • EK 5.1.1A - Programs are developed and used in a variety of ways by a wide range of people depending on the goals of the programmer.
      • EK 5.1.1B - Programs developed for creative expression, to satisfy personal curiosity, or to create new knowledge may have visual, audible, or tactile inputs and outputs.
      • EK 5.1.1C - Programs developed for creative expression, to satisfy personal curiosity, or to create new knowledge may be developed with different standards or methods than programs developed for widespread distribution.
      • EK 5.1.1D - Additional desired outcomes may be realized independently of the original purpose of the program.
    • LO 5.1.2 - Develop a correct program to solve problems. [P2]
      • EK 5.1.2A - An iterative process of program development helps in developing a correct program to solve problems.
      • EK 5.1.2B - Developing correct program components and then combining them helps in creating correct programs.
      • EK 5.1.2C - Incrementally adding tested program segments to correct working programs helps create large correct programs.
    • LO 5.1.3 - Collaborate to develop a program. [P6]
      • EK 5.1.3A - Collaboration can decrease the size and complexity of tasks required of individual programmers.
      • EK 5.1.3B - Collaboration facilitates multiple perspectives in developing ideas for solving problems by programming.
      • EK 5.1.3C - Collaboration in the iterative development of a program requires different skills than developing a program alone.
      • EK 5.1.3D - Collaboration can make it easier to find and correct errors when developing programs.
      • EK 5.1.3E - Collaboration facilitates developing program components independently.
      • EK 5.1.3F - Effective communication between participants is required for successful collaboration when developing programs.
  • EU 5.2 - People write programs to execute algorithms.
    • LO 5.2.1 - Explain how programs implement algorithms. [P3]
      • EK 5.2.1A - Algorithms are implemented using program instructions that are processed during program execution.
      • EK 5.2.1B - Program instructions are executed sequentially.
      • EK 5.2.1C - Program instructions may involve variables that are initialized and updated, read, and written.
      • EK 5.2.1D - An understanding of instruction processing and program execution is useful for programming.
      • EK 5.2.1E - Program execution automates processes.
      • EK 5.2.1J - Simple algorithms can solve a large set of problems when automated.
  • EU 5.3 - Programming is facilitated by appropriate abstractions.
    • LO 5.3.1 - Use abstraction to manage complexity in programs. [P3]
      • EK 5.3.1H - Data abstraction provides a means of separating behavior from implementation.
      • EK 5.3.1I - Strings and string operations, including concatenation and some form of substring, are common in many programs.
      • EK 5.3.1K - Lists and list operations, such as add, remove, and search, are common in many programs.
      • EK 5.3.1L - Using lists and procedures as abstractions in programming can result in programs that are easier to develop and maintain.
      • EK 5.3.1M - Application program interfaces (APIs) and libraries simplify complex programming tasks.
      • EK 5.3.1N - Documentation for an API/library is an important aspect of programming.
      • EK 5.3.1O - APIs connect software components, allowing them to communicate.
  • EU 5.4 - Programs are developed, maintained, and used by people for different purposes.
    • LO 5.4.1 - Evaluate the correctness of a program. [P4]
      • EK 5.4.1A - Program style can affect the determination of program correctness.
      • EK 5.4.1C - Meaningful names for variables and procedures help people better understand programs.
      • EK 5.4.1E - Locating and correcting errors in a program is called debugging the program.
      • EK 5.4.1F - Knowledge of what a program is supposed to do is required in order to find most program errors.
      • EK 5.4.1G - Examples of intended behavior on specific inputs help people understand what a program is supposed to do.
      • EK 5.4.1H - Visual displays (or different modalities) of program state can help in finding errors.
      • EK 5.4.1L - An explanation of a program helps people understand the functionality and purpose of it.
      • EK 5.4.1M - The functionality of a program is often described by how a user interacts with it.
  • 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.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.1G - Intuitive and formal reasoning about program components using Boolean concepts helps in developing correct programs.
      • EK 5.5.1H - Computational methods may use lists and collections to solve problems.
      • EK 5.5.1J - Basic operations on collections include adding elements, removing elements, iterating over all elements, and determining whether an element is in a collection.

Math Common Core Practice:

  • MP1: Make sense of problems and persevere in solving them.
  • MP2: Reason abstractly and quantitatively.
  • MP4: Model with mathematics.
  • MP7: Look for and make use of structure.

Common Core Math:

  • F-IF.1-3: Understand the concept of a function and use function notation
  • F-IF.4-6: Interpret functions that arise in applications in terms of the context

Common Core ELA:

  • WHST 12.5 - Develop and strengthen writing as needed by planning, revising, editing, rewriting
  • WHST 12.6 - Use technology, including the Internet, to produce, publish, and update writing products

NGSS Practices:

  • 2. Developing and using models

Essential Questions

  • How can computing and the use of computational tools foster creative expression?
  • How are vastly different kinds of data, physical phenomena, and mathematical concepts represented on a computer?
  • How does abstraction help us in writing programs, creating computational artifacts and solving problems?
  • How are programs developed to help people, organizations or society solve problems?
  • How are programs used for creative expression, to satisfy personal curiosity or to create new knowledge?
  • How do computer programs implement algorithms?
  • How does abstraction make the development of computer programs possible?
  • How do people develop and test computer programs?
  • Which mathematical and logical concepts are fundamental to computer programming?

Teacher Resources

Student computer usage for this lesson is: required

Lesson Plan

Session 1

Getting Started (5 min)

Introduction [3 min]

Review the string commands. As they enter the class, hand students a copy of the Warm-Up Get Ready for Lists.docx that is found in the Lesson Resources folder.

Discussion [2 min]

Discuss: What is a list? (A sequential collection of Python data values; each value is identified by an index.)

Guided Actvities (40 min)

List Role Play [20 min]

See the file calld LinkyListy Role Play in the Lesson Resources folder. Note: You can change student names to students within your class.

 

Create a human “list of students”.  See the file called LinkyListy Role Play in the Lesson Resources folder. Note: The directions below are an example.  Change student names to students within your class.

Create a List of students by starting with an empty list and modify the list by following program below.


Designate a section of the board or a poster to act as the console/printer for output and a volunteer student to act as the printer driver.


Designate an area at the front of the room for the computer memory (and future students).


As students are called by the program, have each student come up to stand in front of the room where memory resides.


Have each student point to the student that follows them to form a linked list as they come to the front.

 

LinkyListy Role Play Program:
students = []
students.append('Joe')
students.append('Pat')
students.append('Alea')
students.append('Marta')
print(students)
#add additional commands to append or insert 4 or 5 more students
print(students)
print(len(students))
print(students[3])
students.reverse()
print(students)
print('David' in students)
students.sort()
print(students)
more = ['Tom', 'Laverne']
students = students + more
print(students)
pets = ['fish'*3,'dog']
del students[1]
del students[2:4]
students.insert(0, 'Jennifer')
students = students + pets
print(students)
print(students.index('Marta'))

Check for understanding: Ask students to give an example and then explain the effect of several of the List methods. For example, students.append(“Zoe”) would add Zoe to the end of the list of students. students.insert(4, “Larry”) would add Larry at index position 4 and slide everyone else down one slot. This could be done as a placemat activity. Use different colored markers for each student to write the example. Turn placement and ask the next student to explain the effect.

Notes:

  • Length of a list: print(len(students))
  • Accessing Elements: print(students[2])
  • List Membership (in, not in): print(“Mary” in students)
  • Concatenation and repetition (+ *):Make a list of more Python commands on sentence strips. On back of the sentence strip, write the output or trace of the statement after it has executed onto the back of the card. Have one student hold the deck of cards and cycle through them. Ask students to read a card and predict the output. Meanwhile, students who are in the list will change positions to demonstrate the behavior within the list. The holder of the card provides feedback or congratulatoins in checking the correctness of classmate's responses.
  • Include cards that model these behaviors:
more = ["Tom", "Laverne"]
students = students + more
pets =['fish'*3,'dog']*2 # creates a list of ['fishfishfish','dog','fishfishfish','dog']
  • List deletion using the delete operator: del students[2], del students[2:4]
  • List deletion using the List method pop: stu = students.pop(2), stuLast = students.pop(). The pop method pops (deletes and returns) an element at a given index or the last element if no index is provided.
  • Extension: additional list methods that may be useful and interesting: sort, reverse, index, count.

Access Python Documentation [10 min]

  • Check out the Python docs for Built-in Types.
  • Go to Section 4.6 Sequence types- list, tuple, range, and check out the sections on (4.6.1) Common Sequence Operations, (4.6.3) Mutable Sequence Types, and (4.6.4) Lists.  
  • Students need to realize that Application Programmer Interfaces (APIs) are an important resource for programming.
  • Identify list methods found in the API. (Link to resource:  Python API for Built-in Types)

List Slices [10 min]

  • Quickly resurrect your list of students.
  • This time, write names on the board.  
  • To simulate list slices, add each student’s age and hair color after each student’s name.
  • Yes, lists can contain different kinds of objects!
  • Ask students to copy the list and write the code to pull out a sublist that contains the second student’s name and info.

Wrap Up (5 min)

Discussion: How are lists the same and how are they different from Strings?

Homework

Have the students do the Runestone lab activities for Lists to reinforce the above concepts. (http://interactivepython.org/runestone/static/thinkcspy/Lists/toctree.html)

Session 2

Getting Started (5 min)

  • Create a list that contains the integers from 1 to 10.
  • Create the same list from an empty list using a loop.
  • Check for understanding: create a list that counts down from 10 to 1 and then adds “Blastoff”.
  • Reverse a given list.

Guided Activities (40 min)

Lists are Mutable [20 min]

Demonstrate that lists are mutable with the following activity

  • Create a list representing a horse barn containing 4 horses in 6 stalls.
  • Use the built-in constant None for the empty stalls.
  • Find an empty stall.
  • If there is an empty stall, place “Toby” in the Barn in that slot.
  • Also. see if a particular horse is in the barn or if he is out to pasture.
  • Exchange 2 horses in the barn. (Adapted from 2012 APCS exam question 3, page 13 of  http://apcentral.collegeboard.com/apc/public/repository/ap_frq_computerscience_12.pdf)

Paired Programming [20 min]

  • In a group of 2-3, make a zoo of animals.
  • Demonstrate the use of at least 6 different list operations and methods.
  • For a bonus, try to make a story with your code.  

Wrap Up (5 min)

Homework

Create a list of 5 students that contain the students' name, age, and hair color. Use a loop to extract the information for each student and print it out.

Teacher Note: Consider using the YumYumCupcake problem (see Formative Assessment) as part of tomorrow's opening exercises. 


Options for Differentiated Instruction

  • Use a canvas shoe bag to demonstrate a list.
  • Use a parking lot with numbered spaces as an example of a list.

Evidence of Learning

Formative Assessment

  • Create a quiz similiar to the role play. Use the answer chart provided as a template for the quiz. 
  • Check for understanding: Ask students to explain what the effect of the List methods append, insert, etc. For example, students.append “Zoe” would add Zoe to the end of the list of students? Students.insert( 4, “Larry”). Would add Larry at index position 4 and slide everyone else down one slot?
  • Check for understanding: Create a list that counts down from 10 to 1 and then adds “Blastoff”.
  • Let's visit the YumYum Shoppe: Create a list that has different kinds of cupcakes and simulate the actions that might take place during a typical day. For example, yumYumCupcakes = ["chocolate mousse" *3, "vanilla creme", "strawberry fluff", "chocolate mousse"*2]. Have a customer purchase a vanilla creme cupcake if there are any, check how many chocolate mouse cupcakes are in the display case, bake some more, and add them in. Drop one cupcake on the floor and throw it away.

Summative Assessment

Paired programming: Make a zoo of animals and demonstrate the use of at least 6 different list operations and methods. Try to make a story with your code.  

Lesson Summary

Summary

To conclude the unit, students will complete a small project as well as a written assessment.  The project requires students to parse text and search through lists or words to find a specific characteristic.  The assessment covers integers, strings, booleans, loops, if statements, and lists.

Outcomes

  • Students will synthesize concepts from the previous lessons to create their first project in PyCharm.  
  • Students will design a function and determine the relationship between algorithms and functions.

Overview

  1. Getting Started (5 min)
  2. Independent Activity (40 min)
  3. Wrap Up (5 min)

Learning Objectives

CSP Objectives

Big Idea - Creativity
  • EU 1.1 - Creative development can be an essential process for creating computational artifacts.
    • LO 1.1.1 - Apply a creative development process when creating computational artifacts. [P2]
      • EK 1.1.1B - Creating computational artifacts employs an iterative and often exploratory process to translate ideas into tangible form.
  • EU 1.2 - Computing enables people to use creative development processes to create computational artifacts for creative expression or to solve a problem.
    • LO 1.2.3 - Create a new computational artifact by combining or modifying existing artifacts. [P2]
      • EK 1.2.3A - Creating computational artifacts can be done by combining and modifying existing artifacts or by creating new artifacts.
      • EK 1.2.3C - Combining or modifying existing artifacts can show personal expression of ideas.
    • LO 1.2.4 - Collaborate in the creation of computational artifacts. [P6]
Big Idea - Algorithms
  • EU 4.1 - Algorithms are precise sequences of instructions for processes that can be executed by a computer and are implemented using programming languages.
    • LO 4.1.1 - Develop an algorithm for implementation in a program. [P2]
      • EK 4.1.1A - Sequencing, selection, and iteration are building blocks of algorithms.
      • EK 4.1.1B - Sequencing is the application of each step of an algorithm in the order in which the statements are given.
      • EK 4.1.1C - Selection uses a Boolean condition to determine which of two parts of an algorithm is used.
      • EK 4.1.1D - Iteration is the repetition of part of an algorithm until a condition is met or for a specified number of times.
      • EK 4.1.1E - Algorithms can be combined to make new algorithms.
      • EK 4.1.1F - Using existing correct algorithms as building blocks for constructing a new algorithm helps ensure the new algorithm is correct.
      • EK 4.1.1G - Knowledge of standard algorithms can help in constructing new algorithms.
      • EK 4.1.1H - Different algorithms can be developed to solve the same problem.
      • EK 4.1.1I - Developing a new algorithm to solve a problem can yield insight into the problem.
    • LO 4.1.2 - Express an algorithm in a language. [P5]
      • EK 4.1.2A - Languages for algorithms include natural language, pseudocode, and visual and textual programming languages.
      • EK 4.1.2B - Natural language and pseudocode describe algorithms so that humans can understand them.
      • EK 4.1.2C - Algorithms described in programming languages can be executed on a computer.
      • EK 4.1.2G - Every algorithm can be constructed using only sequencing, selection, and iteration.
      • EK 4.1.2I - Clarity and readability are important considerations when expressing an algorithm in a language.
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.1 - Develop a program for creative expression, to satisfy personal curiosity, or to create new knowledge. [P2]
      • EK 5.1.1A - Programs are developed and used in a variety of ways by a wide range of people depending on the goals of the programmer.
      • EK 5.1.1B - Programs developed for creative expression, to satisfy personal curiosity, or to create new knowledge may have visual, audible, or tactile inputs and outputs.
      • EK 5.1.1D - Additional desired outcomes may be realized independently of the original purpose of the program.
    • LO 5.1.2 - Develop a correct program to solve problems. [P2]
      • EK 5.1.2A - An iterative process of program development helps in developing a correct program to solve problems.
      • EK 5.1.2B - Developing correct program components and then combining them helps in creating correct programs.
      • EK 5.1.2C - Incrementally adding tested program segments to correct working programs helps create large correct programs.
      • EK 5.1.2D - Program documentation helps programmers develop and maintain correct programs to efficiently solve problems.
      • EK 5.1.2E - Documentation about program components, such as code segments and procedures, helps in developing and maintaining programs.
      • EK 5.1.2F - Documentation helps in developing and maintaining programs when working individually or in collaborative programming environments.
      • EK 5.1.2G - Program development includes identifying programmer and user concerns that affect the solution to problems.
      • EK 5.1.2I - A programmer's knowledge and skill affects how a program is developed and how it is used to solve a problem.
      • EK 5.1.2J - A programmer designs, implements, tests, debugs, and maintains programs when solving problems.
  • EU 5.2 - People write programs to execute algorithms.
    • LO 5.2.1 - Explain how programs implement algorithms. [P3]
      • EK 5.2.1A - Algorithms are implemented using program instructions that are processed during program execution.
      • EK 5.2.1B - Program instructions are executed sequentially.
      • EK 5.2.1C - Program instructions may involve variables that are initialized and updated, read, and written.
      • EK 5.2.1D - An understanding of instruction processing and program execution is useful for programming.
      • EK 5.2.1I - Executable programs increase the scale of problems that can be addressed.
      • EK 5.2.1J - Simple algorithms can solve a large set of problems when automated.
  • EU 5.3 - Programming is facilitated by appropriate abstractions.
    • LO 5.3.1 - Use abstraction to manage complexity in programs. [P3]
      • EK 5.3.1A - Procedures are reusable programming abstractions.
      • EK 5.3.1B - A procedure is a named grouping of programming instructions.
      • EK 5.3.1C - Procedures reduce the complexity of writing and maintaining programs.
      • EK 5.3.1D - Procedures have names and may have parameters and return values.
      • EK 5.3.1E - Parameterization can generalize a specific solution.
      • EK 5.3.1F - Parameters generalize a solution by allowing a procedure to be used instead of duplicated code.
      • EK 5.3.1G - Parameters provide different values as input to procedures when they are called in a program.
      • EK 5.3.1H - Data abstraction provides a means of separating behavior from implementation.
      • 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.
      • EK 5.3.1K - Lists and list operations, such as add, remove, and search, are common in many programs.
      • EK 5.3.1L - Using lists and procedures as abstractions in programming can result in programs that are easier to develop and maintain.
  • EU 5.4 - Programs are developed, maintained, and used by people for different purposes.
    • LO 5.4.1 - Evaluate the correctness of a program. [P4]
      • EK 5.4.1C - Meaningful names for variables and procedures help people better understand programs.
      • EK 5.4.1D - Longer code segments are harder to reason about than shorter code segments in a program.
      • EK 5.4.1E - Locating and correcting errors in a program is called debugging the program.
      • EK 5.4.1F - Knowledge of what a program is supposed to do is required in order to find most program errors.
      • EK 5.4.1G - Examples of intended behavior on specific inputs help people understand what a program is supposed to do.
      • EK 5.4.1H - Visual displays (or different modalities) of program state can help in finding errors.
      • EK 5.4.1I - Programmers justify and explain a program’s correctness.
      • EK 5.4.1J - Justification can include a written explanation about how a program meets its specifications.
      • EK 5.4.1K - Correctness of a program depends on correctness of program components, including code segments and procedures.
      • EK 5.4.1L - An explanation of a program helps people understand the functionality and purpose of it.
      • EK 5.4.1M - The functionality of a program is often described by how a user interacts with it.
      • EK 5.4.1N - The functionality of a program is best described at a high level by what the program does, not at the lower level of how the program statements work to accomplish this.
  • 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.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.
      • EK 5.5.1G - Intuitive and formal reasoning about program components using Boolean concepts helps in developing correct programs.
      • EK 5.5.1H - Computational methods may use lists and collections to solve problems.
      • EK 5.5.1J - Basic operations on collections include adding elements, removing elements, iterating over all elements, and determining whether an element is in a collection.

Math Common Core Practice:

  • MP1: Make sense of problems and persevere in solving them.
  • MP5: Use appropriate tools strategically.
  • MP6: Attend to precision.
  • MP7: Look for and make use of structure.
  • MP8: Look for and express regularity in repeated reasoning.

Common Core Math:

  • S-ID.1-4: Summarize, represent, and interpret data on a single count or measurement variable

NGSS Practices:

  • 3. Planning and carrying out investigations
  • 5. Using mathematics and computational thinking
  • 8. Obtaining, evaluation, and communicating information

Key Concepts

Students should synthesize concepts from the previous lessons to create their first project in PyCharm.  This lesson also pushes a student to think about how to design a function, and the relationship between algorithms and functions.


Essential Questions

  • How are algorithms implemented and executed on computers and computational devices?
  • What kinds of problems are easy, what kinds are difficult, and what kinds are impossible to solve algorithmically?
  • How are algorithms evaluated?
  • How are programs developed to help people, organizations or society solve problems?
  • How are programs used for creative expression, to satisfy personal curiosity or to create new knowledge?
  • How do computer programs implement algorithms?
  • How do people develop and test computer programs?
  • Which mathematical and logical concepts are fundamental to computer programming?

What are the key elements we need to think about when designing a function?

Teacher Resources

Student computer usage for this lesson is: required

In the Lesson Resources folder:

  • Word Play
  • Word Play Rubric
  • Assessment

Lesson Plan

Getting Started (5 min)

  • Ask the students to work in small groups to create pseudocode for the following function:
  • Create a function titled 'is_palindrome' that inputs a word and determines whether that word is a palindrome.  If it is, return True, otherwise return False.
  • As a class, use the groups' pseudocode to create the function 'is_palindrome'.
  • Introduce the projects to students.  They will have a total of 2 sessions to complete their project. 

Independent Activity (40 min)

Students work individually on the Word Play and Assessment which are found in the lesson resource folder.

Wrap up (5 min)

Allow students to continue working to the end of class on their projects; have individual check-ins with students to make sure that they are on track and have a clear idea of what they need to complete the following day.

 


Options for Differentiated Instruction

Option to allow students to complete Word Play with partners to promote collaboration, then complete the written assessment individually.


Evidence of Learning

Formative Assessment

Teacher will monitor the progress of the students on each of the programs in Word Play.


Summative Assessment

Written assessment (see google drive)

Project Assessment (see google drive for project and rubric)