Chapter 4
Module 2: Intro to Functions &
Data Analysis
Before you teach. . .
You may want to prepare the following before you implement this module in your classroom:
How to teach a lesson. . .
Table of Contents
Lessons
Explorations
Additional Resources
Lesson 1
Introduction to Functions
What did we learn last time?
-How did you use compound conditionals in Ozaria?
-What’s the difference between if/else and else/if conditionals?
-What happened when you met Snikrep and Astra? What did you find out?
-How did you return to Ozaria?
Today’s Journey
Introduction: Functions
Warm Up: Pizza Shop Functions
Play Ozaria: Travel through time and use functions
Optional Extension: Run a Shop with Functions
What are some of your everyday activities?
What are the steps to each of those activities? Do you have to think about each step when you do them?
Functions in Life
Functions are shortcuts that let you simplify steps and instructions. You can put repetitive steps inside a function. Then, you can use the function instead of listing each of those steps.
FUNCTION makePost
OPEN app
START a new post
ADD photo or video
WRITE description
ADD hashtags
TAKE a photo
makePost
MESSAGE with friends
FIND funny cat video
makePost
SCROLL feed
ADD comments
SEE dog chases tail
TAKE a video
makePost
Today’s Social Media Activity
Functions in Code
A function contains a piece of code that you can use over and over again in your program. It provides a shortcut that helps your code stay organized and easier to read.
Original Program
Program with a Function
hero moveRight one
hero moveUp one
hero moveRight one
hero moveUp three times
hero moveRight one
hero moveUp one
hero moveRight one
hero moveDown two times
hero moveRight one
hero moveUp one
hero moveRight one
FUNCTION path
hero moveRight one
hero moveUp one
hero moveRight one
path
hero moveUp three times
path
hero moveDown two times
path
function call
Structured Programming
We are always looking for new ways to make our code faster, efficient, and error proof.
We achieve this with structured programming.
Structured programming uses reusable elements, like variables, to make a program clearer and easy to update.
With regular programming, although it requires less planning ahead, a program is prone to errors and hard to update.
Structured
Regular
Function Parts
A function contains a piece of code that you can use over and over again in your program. It provides a shortcut that helps your code stay organized and easier to read.
FUNCTION path
hero moveRight one
hero moveUp one
hero moveRight one
path
hero moveUp three times
path
hero moveDown two times
path
function call
function definition
function code
function name
Concept Check: Function Parts
Identify the different parts of this program
FUNCTION path
hero moveRight one
hero moveUp one
hero moveRight one
path
hero moveUp three times
path
hero moveDown two times
path
1
2
4
3
Independent Practice
Meet Noodles
You’ll be coding with Noodles the rabbit as a new object, just like you’ve coded with Mouse and other characters.
hero.moveRight()
fox.say("Hi!")
mouse.dig()
noodles.jump()
Independent Practice
Play Ozaria
Start with Cinematic: Before the Storm and stop�after you finish Practice Level: Argumented Rectangles
Run a Pizza Shop with Functions
Use the link provided by your teacher to complete this activity.
Need Help?�Always try it once & try using the troubleshooting guide first. If you still need help after that, then reach out to a classmate or the teacher.
Check-In
What did you discover?
Chapter 4, Module 1, Lesson 1
What I did:
-How far did you get in Ozaria? What was your favorite part?
What I noticed:
-What did you notice as you played through the game?
-Did you discover or learn something new?
What was challenging?�-Was something confusing about the story or the levels?
-Do you need more practice on a specific part of the code or the game?
Lesson 2
Data & Analysis
What did we learn last time?
-How do you use functions in your everyday life?
-How did you use functions to help Noodles collect the glow fruit?
-What happened in Ozaria? What are you trying to make?
Today’s Journey
Review: Data & Analysis
Warm Up: Rock, Paper, Scissors Analysis
Play Ozaria: Use data & analysis to help Noodles
What kind of data have you collected in the past?
Have you collected data through surveys? Spreadsheets? Online tools?
How does data help you make decisions?
How have you used data to help you make predictions and decisions in your life or in past projects?
Data can help you:
Computational Models
Computational models use mathematics and computer science to simulate complex systems. You can change the settings of a model and then see how they cause different outcomes. Then you can use that data to make predictions and decisions.
Rock, Paper Scissors!
Try out a computational model and review the data that you collect.
�
Concept Check: Advanced Rock, Paper Scissors
Use data to set up a strategy and improve your odds of winning!
Everytime, Markov plays rock and rock, then he always follows with paper. What other patterns do you see?
Independent Practice
Noodles Data
You’ll be using a computational model with Noodles. In the model, you’ll:
- Have a goal. You’ll want to deliver X number of fruits by Y number of seconds (this will change each time)
�- Set the number of glow fruits Noodles will carry and her speed
- Use trial and error by trying different settings and running the model to see the results
- Look at the data to notice a pattern, which will help you find the settings that will meet your goal
Independent Practice
Play Ozaria
Start with Cinematic: Moving On and stop�after you finish Cinematic: The Acodus Loop
Graphing Data with Noodles
Use the link provided by your teacher to complete this activity.
Need Help?�Always try it once & try using the troubleshooting guide first. If you still need help after that, then reach out to a classmate or the teacher.
Check-In
What did you discover?
Chapter 4, Module 2, Lesson 2
What I did:
-How far did you get in Ozaria? What was your favorite part?
What I noticed:
-What did you notice as you played through the game?
-Did you discover or learn something new?
What was challenging?�-Was something confusing about the story or the levels?
-Do you need more practice on a specific part of the code or the game?
Module 2, Lesson 3
Explorations
Computing Systems: �Design Your Own Acodus
Computing Systems
Recall the Acodus. What can the Acodus do?
What have you done with it in Ozaria?
Recall the hardware/software of the Acodus.
What are their jobs?
How does hardware/software collect and store data?
Data Exchange
How does phone’s hardware/software collect and exchange data when you use speech recognition?
Hardware�You say the word “stuff” and the mic on your phone records your voice as audio waves. The screen shows how long you’re recording.
stuff
The software inside the phone converts the audio waves into digital data.
Software
Then it breaks up the data into separate sounds.
The sounds are compared to words in an online or built-in dictionary to find a best match.
Hardware�The best match is displayed on the screen. Then you can touch the screen to send or save what you said.
Analyze the Acodus
What can the Acodus do now? How does its hardware and software collect and exchange data?
hero.moveLeft()
hero.moveUp()
hero.moveRight()
hero.use("door")
Computer System Schematic
Input (includes sensors)
Output
Processor
Memory
Analyze the User Interface
How do you interact with the Acodus when you code?
Improve the Acodus
How would you improve the Acodus? Think about the features you could change: hardware, software, data collection, user interaction, etc.
hero.moveLeft()
hero.moveUp()
hero.moveRight()
hero.use("door")
Design Your Own Acodus
Design a new Acodus that includes some or all of the improvements you’ve written down in the worksheet. Your design documents should include the following:
hero.moveLeft()
hero.moveUp()
hero.moveRight()
hero.use("door")
Share
Let’s present your designs!
Resources
Standards Alignment & Additional Resources
CSTA Standards Alignment
Computing Systems
-2-CS-01: Recommend improvements to the design of computing devices, based on an analysis of how users interact with the devices.
-2-CS-02: Design projects that combine hardware and software components to collect and exchange data.
Data and Analysis
-2-DA-08: Collect data using computational tools and transform the data to make it more useful and reliable.
-2-DA-09: Refine computational models based on the data they have generated.
Algorithms & Programming
-1A-AP-10: Develop programs with sequences and simple loops, to express ideas or address a problem.
-1A-AP-11: Decompose (break down) the steps needed to solve a problem into a precise sequence of instructions.
-1A-AP-14: Debug (identify and fix) errors in an algorithm or program that includes sequences and simple loops.
-1A-AP-15: Using correct terminology, describe the steps taken and choices made during the iterative process of development.
-1B-AP-10: Create programs that include sequences, events, loops, and conditionals.
-1B-AP-11: Decompose (break down) problems into smaller, manageable subproblems to facilitate the program development process.
-1B-AP-12: Modify, remix, or incorporate portions of an existing program into one's own work, to develop something new or add more advanced features.
CSTA Standards Alignment
Algorithms & Programming (continued)
-1B-AP-15: Test and debug (identify and fix errors) a program or algorithm to ensure it runs as intended.
-2-AP-13: Decompose problems and subproblems into parts to facilitate the design, implementation, and review of programs.
-2-AP-14: Create procedures with parameters to organize code and make it easier to reuse.
-2-AP-15: Seek and incorporate feedback from team members and users to refine a solution that meets user needs.
-2-AP-17: Systematically test and refine programs using a range of test cases.
Common Core State Standards
Writing
-CCSS.ELA-LITERACY.W.6.6: Use technology, including the Internet, to produce and publish writing as well as to interact and collaborate with others; demonstrate sufficient command of keyboarding skills to type a minimum of three pages in a single sitting.
-CCSS.ELA-LITERACY.W.6.10/CCSS.ELA-LITERACY.W.7.10/CCSS.ELA-LITERACY.W.8.10: Write routinely over extended time frames (time for research, reflection, and revision) and shorter time frames (a single sitting or a day or two) for a range of discipline-specific tasks, purposes, and audiences.
-CCSS.ELA-LITERACY.W.7.4/CCSS.ELA-LITERACY.W.8.4: Produce clear and coherent writing in which the development, organization, and style are appropriate to task, purpose, and audience.
-CCSS.ELA-LITERACY.W.7.6: Use technology, including the Internet, to produce and publish writing and link to and cite sources as well as to interact and collaborate with others, including linking to and citing sources.
-CCSS.ELA-LITERACY.W.8.6: Use technology, including the Internet, to produce and publish writing and present the relationships between information and ideas efficiently as well as to interact and collaborate with others.
Speaking & Listening
-CCSS.ELA-LITERACY.SL.6.1/CCSS.ELA-LITERACY.SL.7.1/CCSS.ELA-LITERACY.SL.8.1: Engage effectively in a range of collaborative discussions (one-on-one, in groups, and teacher-led) with diverse partners on grade 6-8 topics, texts, and issues, building on others' ideas and expressing their own clearly.
Common Core State Standards
Speaking & Listening (continued)
-CCSS.ELA-LITERACY.SL.6.4: Present claims and findings, sequencing ideas logically and using pertinent descriptions, facts, and details to accentuate main ideas or themes; use appropriate eye contact, adequate volume, and clear pronunciation.
-CCSS.ELA-LITERACY.SL.6.6/CCSS.ELA-LITERACY.SL.7.6/CCSS.ELA-LITERACY.SL.8.6: Adapt speech to a variety of contexts and tasks, demonstrating command of formal English when indicated or appropriate.
-CCSS.ELA-LITERACY.SL.7.4/CCSS.ELA-LITERACY.SL.8.4/: Present claims and findings, emphasizing salient points in a focused, coherent manner with pertinent descriptions, facts, details, and examples; use appropriate eye contact, adequate volume, and clear pronunciation.
Common Core State Standards
Math: Expressions & Equations
-CCSS.MATH.CONTENT.6.EE.A.2: Write, read, and evaluate expressions in which letters stand for numbers.
-CCSS.MATH.CONTENT.6.EE.B.6: Use variables to represent numbers and write expressions when solving a real-world or mathematical problem; understand that a variable can represent an unknown number, or, depending on the purpose at hand, any number in a specified set.
-CCSS.MATH.CONTENT.6.EE.B.8: Write an inequality of the form x > c or x < c to represent a constraint or condition in a real-world or mathematical problem. Recognize that inequalities of the form x > c or x < c have infinitely many solutions; represent solutions of such inequalities on number line diagrams.
-CCSS.MATH.CONTENT.6.EE.C.9: Use variables to represent two quantities in a real-world problem that change in relationship to one another; write an equation to express one quantity, thought of as the dependent variable, in terms of the other quantity, thought of as the independent variable. Analyze the relationship between the dependent and independent variables using graphs and tables, and relate these to the equation. For example, in a problem involving motion at constant speed, list and graph ordered pairs of distances and times, and write the equation d = 65t to represent the relationship between distance and time.
-CCSS.MATH.CONTENT.7.EE.B.4: Use variables to represent quantities in a real-world or mathematical problem, and construct simple equations and inequalities to solve problems by reasoning about the quantities.
Math: Statistics & Probability
-CCSS.MATH.CONTENT.7.SP.A.2: Use data from a random sample to draw inferences about a population with an unknown characteristic of interest. Generate multiple samples (or simulated samples) of the same size to gauge the variation in estimates or predictions
Common Core State Standards
Math: Statistics & Probability (continued)
-CCSS.MATH.CONTENT.7.SP.C.7: Develop a probability model and use it to find probabilities of events. Compare probabilities from a model to observed frequencies; if the agreement is not good, explain possible sources of the discrepancy.
-CCSS.MATH.CONTENT.7.SP.C.8: Find probabilities of compound events using organized lists, tables, tree diagrams, and simulation.
-CCSS.MATH.CONTENT.8.SP.A.4: Understand that patterns of association can also be seen in bivariate categorical data by displaying frequencies and relative frequencies in a two-way table. Construct and interpret a two-way table summarizing data on two categorical variables collected from the same subjects.
Resource Links
Teacher Materials
-Chapter 4 Solution Guide - Python
-Chapter 4 Solution Guide - JavaScript
Student Materials�-Check-in Journal Template
-Lesson 1 Extension Activity: Run a Pizza Shop with Functions
-Lesson 2 Extension Activity: Graphing Data with Noodles
-Rock, Paper, Scissors Activity
-Introduction Tutorial, Advanced Tutorial
-Computing System Articles
-Speech Recognition for Learning
-How Stuff Works: Speech Recognition
-Automatic Speech Recognition Systems
-Acodus Design Tools
-Sketch Up, Fusion 360, Figma, Google Drawings, Adobe Spark, Adobe Spark Web Design