Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Computational Thinking

Similar presentations


Presentation on theme: "Introduction to Computational Thinking"— Presentation transcript:

1 Introduction to Computational Thinking
BlockPy Lists & Iteration (C) Dennis Kafura

2 Recall: Lists in BlockPy
A list is a data structure that represents an abstraction with multiple instances Simple lists have instances with only one property A list represents a “big data” data set Writing a list “by hand” “Big Data” list block (C) Dennis Kafura

3 Recall: Iteration in BlockPy
BlockPy has blocks for iteration Use iteration to process a data set (i.e., a list) Different patterns for processing a data set Uniform Accumulate Transform Filter List Property Iteration Property Iteration Actions go here Singular and plural (C) Dennis Kafura

4 Patterns Uniform: perform the same processing on each element of the list Accumulate: determine a property of the list Transform: produce a new list by processing the elements of an existing list Filter: use a decision to select some elements of the list for processing (C) Dennis Kafura

5 Transform pattern Motivation: generate a “transformation” of the abstraction being processed Create a list of forecast temperatures in Celsius from a list of temperatures in Fahrenheit. Create a list of “feels like” temperatures from a list of weather forecasts that give temperature and wind speed. Create a list that categorizes each state’s crime rate as high, medium, or low from a list of crime rates by state. 4 14 9 2 15 7 10 How do we go from here… To this? 8 28 18 4 30 14 20 (C) Dennis Kafura

6 Transform pattern Creates a new list based on an existing list
Uses list operations create an empty list append (“add”) a new item to end of a list Before Iteration During Iteration (C) Dennis Kafura

7 Transform pattern iteration Existing List A Process: A -> B
New List B append (C) Dennis Kafura

8 Transform in action List Property representing an Abstraction
Property representing a New List Iteration Put stuff into our New List Property *Vocab: “Append” means “Add to end” (C) Dennis Kafura

9 Plotting Making lists means making plots!
A list of numbers (over time) Two equal-sized lists of numbers Any list of numbers Actually draw the plot Awesome people give titles (C) Dennis Kafura

10 Plot, then Show After you plot… YOU MUST SHOW (C) Dennis Kafura

11 Print vs Plotting Printing is for Quantitative Measures
Plotting is for lists (C) Dennis Kafura

12 Filter pattern Motivation: in big data only certain occurrences may be of interest Big earthquakes Temperatures above or below a certain threshold A high or low crime rate Mechanism: combine iteration – to provide each element one at a time decision – use each element that passes the filter test and ignore others (C) Dennis Kafura

13 Filter pattern iteration Existing List A If filter test for A is false
true A append New List (C) Dennis Kafura

14 Filtering in BlockPy Iteration Decision Append (C) Dennis Kafura

15 Next steps today Work on the assigned BlockPy and list problems in the book using iteration and decision Work as an individual Seek help from and provide help to your cohort Go as far and as fast as you can remembering to keep everyone in your cohort on board Cohort feedback/reports (C) Dennis Kafura


Download ppt "Introduction to Computational Thinking"

Similar presentations


Ads by Google