BMI for everyone. Compsci 6/101: PFTW. Accumulating a value. How to solve an APT. Review how APTs and Python work, run

Similar documents
Plan For the Week. Solve problems by programming in Python. Compsci 101 Way-of-life. Vocabulary and Concepts

Compsci 290.3, Spring 2017 Software Design and Implementation: Mobile Landon Cox Owen Astrachan

Hoboken Public Schools. PLTW Introduction to Computer Science Curriculum

Text UI. Data Store Ø Example of a backend to a real Could add a different user interface. Good judgment comes from experience

TAFTW (Take Aways for the Week) APT Quiz and Markov Overview. Comparing objects and tradeoffs. From Comparable to TreeMap/Sort

Chapter 8: Recursion

Review: Background on Bits. PFTD: What is Computer Science? Scale and Bits: Binary Digits. BIT: Binary Digit. Understanding scale, what does it mean?

Standard Indicator Europe, Mexico, Canada

Together in the European Union

4/29/2015. Conditions for Patentability. Conditions: Utility. Juicy Whip v. Orange Bang. Conditions: Subject Matter. Subject Matter: Abstract Ideas

Hoboken Public Schools. Project Lead The Way Curriculum Grade 8

Lab 11: Pair Programming. Review: Pair Programming Roles

Fall 2016 COP 3223H Program #5: Election Season Nears an End Due date: Please consult WebCourses for your section

Breaking News English.com Ready-to-Use English Lessons by Sean Banville

Prim's MST Algorithm with step-by-step execution

Have you ever thought about what it would be like to be president of the United States?

Mojdeh Nikdel Patty George

Large Group Lesson. Introduction Video This teaching time will introduce the children to what they are learning for the day.

Objec&ves. Review. So-ware Quality Metrics Sta&c Analysis Tools Refactoring for Extensibility

Capitalism in an Age of Robots

Tie Breaking in STV. 1 Introduction. 3 The special case of ties with the Meek algorithm. 2 Ties in practice

Learning Expectations

Congress Lobbying Database: Documentation and Usage

Kruskal's MST Algorithm with step-by-step execution

Chapter 11. Weighted Voting Systems. For All Practical Purposes: Effective Teaching

Hoboken Public Schools. Geometry Curriculum

Review of Lab 9. Review Lab 9. Social Network Classes/Driver Data. Lab 10 Design

Overview. Ø Neural Networks are considered black-box models Ø They are complex and do not provide much insight into variable relationships

Major Differences Between Prosecution at EPO and JPO

2143 Vote Count. Input

Real-Time Scheduling Single Processor. Chenyang Lu

Comparison of the Psychometric Properties of Several Computer-Based Test Designs for. Credentialing Exams

LobbyView: Firm-level Lobbying & Congressional Bills Database

6. Voting for the Program will be available for five (5) weeks from Monday 13 June 2016.

Analyzing proofs Introduction to problem solving. Wiki: Everyone log in okay? Decide on either using a blog or wiki-style journal?

CHE 572: Modelling Process Dynamics

Report on the Trafficking in Human Being awareness survey among Ukrainian migrants staying in Poland.

Grace For President. He had cleverly calculated. more electoral votes than. that the boys held slightly. the girls. ~Grace For President.

Coverage tools Eclipse Debugger Object-oriented Design Principles. Oct 26, 2016 Sprenkle - CSCI209 1

Voting Corruption, or is it? A White Paper by:

Hoboken Public Schools. Culinary Arts II Curriculum

Vol. 03 Testing ballots for usability

Teacher s guide. Ngā Pōti ā-taiohi Youth Voting 2019 for the local government elections

Hoboken Public Schools. AP Statistics Curriculum

The Art of Blogging. Jessica Lipnack AOKM 30 October NetAge, Inc.

A New Computer Science Publishing Model

Fair Division in Theory and Practice

A Kit for Community Groups to Demystify Voting

Constitution Day Lesson STEP BY STEP

Distributive Justice Rawls

Lesson Plan Subject: Mathematics/Science (8 th -12th grades)

LISTEN A MINUTE.com. Immigration. One minute a day is all you need to improve your listening skills.

DRAFT RECOMMENDATION ON THE PROMOTION AND USE OF MULTILINGUALISM AND UNIVERSAL ACCESS TO CYBERSPACE OUTLINE

Section 36 3 The Integumentary System Answers

IceCube Project Monthly Report December 2005

Hoboken Public Schools. Environmental Science Honors Curriculum

Hoboken Public Schools. College Algebra Curriculum

Google App Engine 8/10/17. CS Cloud Compu5ng Systems--Summer II 2017

8. Interpret the past within its own historical context rather than in terms of present-day norms and values. (H, E, C)

ecourts Attorney User Guide

Hoboken Public Schools. Algebra II Honors Curriculum

Maps and Hash Tables. EECS 2011 Prof. J. Elder - 1 -

The American Colonies and Their Government

Challenges of Supervision: lazy rats, shopping math, and the internet

Lesson 25: Discussing Agenda / Problems (20-25 minutes)

CS 5523: Operating Systems

The Federal in Federalism STEP BY STEP

14 Managing Split Precincts

Justice in general. We need to distinguish between the following: Formal principle of justice. Substantive principles of justice

Arithmetic I. Activity Collection Sample file. Featuring real-world contexts: by Frank C. Wilson

Case 1:18-cv Document 5-2 Filed 06/28/18 Page 1 of 9 IN THE UNITED STATES DISTRICT COURT FOR THE DISTRICT OF COLUMBIA

Using Appointment Slots

A.B.A.T.E. OF ILLINOIS

Teacher s Science Talk and Preschoolers Engagement and Learning

Crime Free Multi-Housing Program

IBM Cognos Open Mic Cognos Analytics 11 Part nd June, IBM Corporation

Bill ideas may come from a Representative or from a citizen like you. Citizens who have ideas for laws can contact their Representatives to discuss

LAW OFFICE MANAGEMENT: HOW TO MAKE MONEY AS A LAWYER INFORMATION & POLICIES FOR SPRING 2017 CHARLES BROWN

Cyber-Physical Systems Feedback Control

Distributive Justice Rawls

Unit 10: Prime Minister You!

CANADA TRADEMARK APPLICATION INFORMATION FORM 1. CLIENT INFORMATION: Name: Address: Telephone: Facsimile: 2. CASE REFERENCE: 3.

POLICY BRIEF One Summer Chicago Plus: Evidence Update 2017

First Missouri State Capitol State Historic Site Educator s Guide

Middle-Childhood Lesson Plan By Whitney Whitehair

CITIZEN ADVOCACY CENTER

ISSUING SMALL CLAIMS The Court Process

Subjects include, but don t stop with

Trial Preparation: Collaborating with Outside Counsel Under Pressure. October 7, 2014

News English.com Ready-to-use ESL / EFL Lessons

FROM JOURNALIST TO CODER: THE RISE OF JOURNALIST-PROGRAMMERS. Yang Sun. David Herzog, Project Supervisor ANALYSIS

Can You Spot the Deceptive Facebook Post?

RULES OF TENNESSEE DEPARTMENT OF ENVIRONMENT AND CONSERVATION CHAPTER ELECTRONIC REPORTING TABLE OF CONTENTS

J-1 professor/research Scholar category Is eligible for 5-yrs maximum stay in teaching or research.

WORKGROUP S CONSENSUS PROCESS AND GUIDING PRINCIPLES CONSENSUS

Definition Traits Benefits History Statistics. 1/10/2013 Social Networking SIG 2

INTEGRITY APPLICATIONS, INC. (Exact name of registrant as specified in its charter)

Panel: Norms, standards and good practices aimed at securing elections

Non-fiction: Who Are We? istockphoto

Hoboken Public Schools. Algebra I Curriculum

Transcription:

Compsci 6/101: PFTW Review how APTs and Python work, run Ø Good, Bad, Ugly: getting better, avoid frustration, Ø How do you run/test APT code, other Python code BMI for everyone How do we get at the data in a Google form? Ø Why would we use a Google form? Ø Advantages of data in the cloud? Shared data? Control flow in Python Ø Changing order in which Python statements execute Ø Loops and if statements Ø Essential for writing real programs Get ready for first assignment Ø Difference between assignment and APTs? How do we find BMI for one person Ø Must do this before we do it for 100 people Ø What do we do about dirty data? Looping and accumulating values Ø The programming idiom of v = v + 55 Ø Generalized: total += value 4.1 4.2 Accumulating a value Variables in Python: name, type, value Ø The name is a label on an "object", "box", value Ø What does v = v + 52 do? How to solve an APT Two very, very, very important steps 1. How to solve the problem with Paper, Pencil, (Calculator) 2. How to translate problem-solving to Python Executing the assignment statement Ø Evaluate expression on right hand side Ø When done store the value of expression with label on left Ø Can this result in changing the value of the variable? Ø Does this change the name of the variable? Advantages of x += 1, or cool_value += 1 Both steps can be hard, vocabulary and language are initially a real barrier Ø The more experience you have with Python, the easier step 2 will get Ø The more you understand the idioms and power of the language the more you can let step 2 influence step 1 Step 1 is key, without it you won t get anywhere 4.3 4.4

APT Pancake Three pancakes in a two-cake pan How do you solve this problem? Ø First steps: are there simple cases that can be solved immediately? What are these for the pancake problem? How will you identify with Python? Ø First 5 minutes Ø Second 5 minutes Ø Sometimes it helps to know if you are on track, use Python to check your paper and pencil work Get specific, solve for 5, not N Ø Fix one parameter, vary the other Ø Identify the cases and continue A B C C B' A 4.5 4.6 Three pancakes in a two-cake pan How to teach pancake flipping Ø Third 5 minutes How many minutes to cook all three pancakes? http://www.youtube.com/watch?v=w_gxlksssie Ø Is this computer science? http://bit.ly/zykorh Ø For longer, more complex robotic tasks http://www.youtube.com/watch?v=4usoe981e7i C' A' B'' A'' B'' C'' Back to specifics: Ø Capacity = 5 Ø Numcakes = 1,2, 5? Ø Numcakes = 6,7,8,9,10? Ø Numcakes = 11,12,13,14,15? Is five special? 4? 3? 2? 4.7 4.8

Eclipse Interlude Finishing the Pancake problem Ø Translating problem-solving ideas to code Ø Control with if/elif: arithmetic with / and % Lessons: special cases, abstractions There are special cases in many, many problems Ø Identifying them is important Ø Abstracting them away when possible is important Ø Example: SilverDistance APT Instead of four quadrants/cases, reducible to two? Instead of (x,y) and (z,w) translate to (0,0) and (z-x,w-y) Translating ideas into (Python) code Ø How do we create interesting heads, totem poles? Ø How do create software for identikit? Ø How do we create Facebook, Foursquare, 4.9 4.10 What years are leap years? 2000, 2004, 2008, Ø But not 1900, not 2100, yes 2400! Ø Yes if divisible by 4, but not if divisible by 100 unless divisible by 400! (what?) def is_leap_year(year): if year % 400 == 0: if year % 100 == 0: if year % 4 == 0: There is more than one way to skin a cat, but we need at least one way Python if statements and Booleans In python we have if: else: elif: Ø Used to guard or select block of code Ø If guard is True then, else other What type of expression used in if/elif tests? Ø ==, <=, <, >, >=,!=, and, or, not, in Ø Value of expression must be either True or False Ø Type == bool, George Boole, Boolean, Examples with if Ø String starts with vowel Ø Rock, paper, scissors (!aka Rochambeau) winner 4.11 4.12

Grace Murray Hopper (1906-1992) How do you solve a problem like? third programmer on world's first large-scale digital computer US Navy: Admiral It's better to show that something can be done and apologize for not asking permission, than to try to persuade the powers that be at the beginning Translating English to Piglatin Why is this fascinating? http://www.google.com/webhp?hl=xx-piglatin Is this like translating English to German? Is it like translating Python to bytecode? downplay their unique quiet strength ownplay-day eir-thay unique-way iet-quay ength-stray What are the rules for pig-latin? See APT ACM Hopper award given for contributions before 35 2004: Jennifer Rexford 2008: Dawson Engler 2010: Craig Gentry: http://www.youtube.com/watch?v=qe-zmhopw30 4.13 APT Piglatin Three versions of is_vowel How do you solve this problem? if ch =='e': if ch == 'a': if ch == 'i': if ch == 'o': if ch == 'u': First steps: are there simple cases that can be solved immediately? What are these for the piglatin problem? How will you identify with Python? Words that begin with Vowel Foods that begin with the letter q for 200 Alex Translation to Python First q, then vowels 4.14 4.15 c = "aeiou".count(ch) if c > 0: else return "aeiou".count(ch) > 0 4.16

Piglatin, age-stay one-way return s+"-way" Preview of next lab: slicing, concatenation, index Ø Where does string-indexing start? Ø What does slice with a single parameter do? Piglatin, age-stay o-tway return s+"-way" if is_vowel(s[1]): return s[1:]+"-"+s[0]+"ay" if is_vowel(s[2]): return s[2:]+"-"+s[:2]+"ay" if is_vowel(s[3]): return s[3:]+"-"+s[:3]+"ay" if is_vowel(s[4]): return s[4:]+"-"+s[:4]+"ay" 4.17 4.18 Piglatin, age-stay ee-threay return s + "-way" for index in range(1,len(s)): if is_vowel(s[index]): return s[index:]+"-"+s[:index]+"ay" Generalize/parameterize by what varies Ø What does a loop do? it repeats! 4.19 Dawson Engler ACM Hopper Award 2008 "In his papers on automated program checking, Dawson Engler introduces and develops powerful techniques and tools for practical program analysis for finding errors in code." Started coverity.com Ø Very successful startup to find errors in code http://myvideos.stanford.edu/player/slplayer.aspx?course=cs240&p=true 4.20