A Programming Approach to the CS Principles Data Task
(from The Beauty and Joy of Computing team)
bjc.berkeley.edu
UC Berkeley Sr Lecturer SOE
Dan Garcia
2 / 25 A Programming Approach to the CS Principles Data Task
Broadening Participation in HS CS! § New Course: “Computer Science : Principles”
ú Engaging, accessible, inspiring, rigorous ú Focused on the fundamental concepts of computing
(Computational Thinking) ú An impetus for college curriculum reform ú Available nationwide, Fall 2016-Spring 2017
§ SINGLE SOURCE OF NATIONAL LEVERAGE!
csprinciples.org
4 / 25 A Programming Approach to the CS Principles Data Task
CSP Curricular Framework: Data 3. Data and Information
1. People use computer programs to process information to gain insight and knowledge.
1. Use computers to process information, find patterns, and test hypotheses about digitally processed information to gain insight and knowledge
2. Collaborate when processing information to gain insight and knowledge 3. Explain the insight and knowledge gained from digitally processed data by using
appropriate visualizations, notation, and precise language
2. Computing facilitates exploration and the discovery of connections in information.
1. Extract information from data to discover and explain connections, patterns, or trends (Students are not expected to know specific formulas or options available in spreadsheet or database software packages)
2. Use large data sets to explore and discover information and knowledge
3. There are trade-offs when representing information as digital data 1. Analyze how data representation, storage, security, and transmission of data
involve computational manipulation of information
UC Berkeley’s BJC The Beauty and Joy of Computing
• 2009Fa : 16 students (pilot) • 2010Fa : 90 students • 2011Sp : 90 students • 2011Su : ~25 HS teachers in BJC Family! • 2011Fa : 250 Students • 2012Sp : 250 Students • 2012Su : ~100 HS teachers online! • 2012Fa : 250 Students & 60 UCB online pilot • 2013Sp : 250 Students • 2013Su: ~175 HS teachers in BJC Family! • 2013Fa : 360 Students • 2014Sp: 250 Students • 2014Su: ~250 HS teachers (~10 faculty) in BJC Family
bjc.berkeley.edu
Grant Winner
Award Winner Pilot
UC Online
Pilot x3
AP CS Principles
6 / 25 A Programming Approach to the CS Principles Data Task
Let’s double all of your salaries!
Write a function now!
Input: list of salaries
Output: new list of doubled salaries
Go! (you can work in teams)
7 / 25 A Programming Approach to the CS Principles Data Task
First try using repeat block
8 / 25 A Programming Approach to the CS Principles Data Task
First try using repeat block … yay!
9 / 25 A Programming Approach to the CS Principles Data Task
First try using for block
10 / 25 A Programming Approach to the CS Principles Data Task
First try using for block … yay!
11 / 25 A Programming Approach to the CS Principles Data Task
First try using for each block
12 / 25 A Programming Approach to the CS Principles Data Task
First try using for each block … yay!
13 / 25 A Programming Approach to the CS Principles Data Task
But can we do better?
14 / 25 A Programming Approach to the CS Principles Data Task
One line!!
15 / 25 A Programming Approach to the CS Principles Data Task
Why use functions? (review)
The power of generalization!
16 / 25 A Programming Approach to the CS Principles Data Task
But how general can we be?
The power of generalization!
?
17 / 25 A Programming Approach to the CS Principles Data Task
§ Functions as Data § Useful HOFs (you can build your own!)
ú map Reporter over List Report a new list, every element E of List becoming Reporter(E)
ú keep items such that Predicate from List Report a new list, keeping only elements E of List if Predicate(E)
ú combine with Reporter over List Combine all the elements of List with Reporter(E) This is also known as “reduce”
§ Acronym example ú keep è map è combine
Higher-Order Functions
combine with Reporter over List a b
c
d
19 / 25 A Programming Approach to the CS Principles Data Task
HOFs are one of our Big Ideas! § Functions as data is
one of the two (programming) big ideas in this course
§ It’s a beautiful example of the abstraction of the list iteration details
§ Google (and other companies) use this! ú They use “map-reduce”
(Credit: Geekologie)
(Image Credit: Simply Scheme by Brian Harvey & Matt Wright)
20 / 25 A Programming Approach to the CS Principles Data Task
§ Useful HOFs (can also build your own!) ú map Reporter over List
Report a new list, every element E of List becoming Reporter(E)
ú keep items such that Predicate from List Report a new list, keeping only elements E of List if Predicate(E)
ú combine with Reporter over List Combine all the elements of List with Reporter(E) This is also known as “reduce”
Higher-Order Functions (HOFs)
bjc.berkeley.edu snap.berkeley.edu
21 / 25 A Programming Approach to the CS Principles Data Task
Big Data: 1880 baby names, let’s do it
Name Gender Number Mary F 7065 Anna F 2604
… … … John M 9655
William M 9532 … … …
22 / 25 A Programming Approach to the CS Principles Data Task
Visualization … Epic FAIL www.huffingtonpost.com/2014/03/31/fox-news-obamacare-graphic_n_5063582.html
Fox News Graphic on the “Obamacare” Enrollment as of 2014-03-27
23 / 25 A Programming Approach to the CS Principles Data Task
Visualization … Epic WIN (1869) www.edwardtufte.com/tufte/posters
Charles Joseph Minard, Napoleon’s 1812 Russian Campaign
24 / 25 A Programming Approach to the CS Principles Data Task
youtu.be/jbkSRLYSojo
Visualization … Epic WIN (2009)
25 / 25 A Programming Approach to the CS Principles Data Task
Resources § Snap: http://snap.berkeley.edu/ § BJC: http://bjc.berkeley.edu/ § BJC Data Lecture slides
ú https://inst.eecs.berkeley.edu/~cs10/sp14/Lectures/L18%20-%20Data/
§ BJC Lab Curriculum (Topic 14 Data Unit): http://bjc.berkeley.edu/bjc-r/course/cs10_sp14.html ú GPS “forensics” activity ú Spam vs Ham detector
§ “An unusual episode” : http://www.amstat.org/publications/jse/v3n3/datasets.dawson.html
ú Usually done without computers; by providing raw data you can open up a computer-based task, however: http://tinyurl.com/BJC-UnfortunateEpisode
Top Related