61A Lecture 14. Friday, October 4

Similar documents
Chapter 12: Real Estate Contracts

Summer Scholars Institute 2016 Schedule of Events

Riscure User Workshop & CHES 2018

Things to consider when buying a Home

STAFF REPORT FOR MONDAY, MAY 9, 2016 MAYOR AND TOWN COUNCIL OF SYKESVILLE

Course Income Approach To Value. Course Description

IDA COUNTY IOWA OFFICE OF COUNTY TREASURER 401 Moorehead St Ida Grove IA Phone: Fax:

ARLINGTON COUNTY, VIRGINIA

Course Overview. Administrative Issues

RULES OF THE DORMITORY OF MEDICAL UNIVERSITY OF BIAŁYSTOK GENERAL PROVISIONS

Department of Residence Life Apartment Living Agreement- Davis Square and Opus Hall

LORI HESSE 110 Allamakee Street ~ Waukon, IA Phone Fax

PASCO COUNTY BINGO LICENSE APPLICATION COUNTY ORDINANCE 92-15, AS AMENDED LICENSE APPLIED FOR A B BOTH

RESERVING OF CLUBHOUSE

Contracts 101. Colette Massengale, Esq. Jason Brand, Esq. Legal Affairs Maryland Association of REALTORS

SOCIAL MEDIA POLICY TOWNSHIP OF WYCKOFF, NEW JERSEY

Township of Kawkawlin

Pebble Creek at Meadow Woods

GATE OPERATION AND RULES A Users Guide, if you will

How to Answer Your Eviction Case

REAL ESTATE CAREER INFORMATION SESSION

10 December 12, 2012 Public Hearing APPLICANT: DAVE & BUSTERS, INC.

WorldMark, The Club Guidelines

STRAWBERRY HILL APARTMENT HOMES

VILNIUS COOPERATIVE COLLEGE INTERNAL DORMITORY PROCEDURE REGULATIONS I CHAPTER GENERAL PROVISIONS II CHAPTER ACCOMODATION IN THE DORMITORY

NC State Greek Village Room Agreement

Please note: Only residents of Central Apartments may hire the Rooftop Terrace Amenities.

NEW PALESTINE LIONS COMMUNITY CENTER 5242 W. US 52, P. O. BOX 492, NEW PALESTINE, IN LEASE AGREEMENT (Non-Members)

Our second speaker is Evelyn Lugo. Evelyn has been bringing buyers and sellers together for over 18 years. She loves what she does and it shows.

2017 Entry Packet New Construction

JUNE 2016 PARADE OF HOMES BUILDER CONTRACT

APPLICATION: MOBILE VENDING UNIT PERMIT

Chapter 14 RATIONAL EXPRESSIONS AND EQUATIONS

THE 2018 MADERA DISTRICT FAIR

General Terms and Conditions of Hexpol Compounding, s.r.o. as of

MEMORANDUM. SUBJECT: Status Report DATE: April 21, 2016

This contract is for the Summer of Dates of occupancy are:

How to Participate. July 24, 2015

CAZENOVIA COLLEGE HOUSING & MEAL PLAN SELECTION MANUAL

Cook Campus IMPORTANT INFORMATION HOUSING SELECTION PROCESS! NEW THIS YEAR LOTTERY NUMBER SELECTION!

PLANNING APPROVAL STAFF REPORT Date: January 18, 2018

City of North St. Paul Park Rental Policy. [This page intentionally left blank.]

MINOR VOLUNTEER APPLICATION (16 years and under)

West Baton Rouge Community Centers User Application and Contract Operated by The West Baton Rouge Parish Parks and Recreation Department

INSTRUCTIONS FOR VARIANCE APPLICATIONS Single-family or Two-Family Residential Properties (No Subdivision or Site Plan Application)

RouteOne LLC / RouteOne Canada Corp. ( RouteOne ) 2015 Gift Card Giveaway. Incentive Program - Official Program Rules

H O U S I N G P O S T

CLASS ANNOUNCEMENT HERITAGE PROTECTION CLASSES

ALFRED TEBBE JR Jackson County Treasurer 201 W Platt St Maquoketa,Iowa 52060

POLICIES AND GENERAL TERMS & CONDITIONS

Elko Community Center Facility Reservation Guide

How a Landlord Can End a Tenancy

General Business Terms and Conditions. I. General provisions

THE RIGHT OF FIRST REFUSAL GUIDE

Talamore Community Association Clubhouse Rental Agreement All Assessments Must Be Current in Order To Rent The Clubhouse

December 13, delivery: To: Subject: File Reference No

Rental Policies & Procedures

2018 VENDOR HANDBOOK

2018 BHHBA FALL PARADE OF HOMES

Town of South Berwick Contact: Public Sale of Tax Acquired Property. Tax Map 10 Lot 30. Bid Packet

Upstate Medical University. Security Assessment of the Syracuse Galleries

Campus of the FIT Hermannsburg Rule of the House

Oakland Berkeley Association of REALTORS Grants Program is still open till end of March click here for more information

City of Firebaugh ANNUAL CANTALOUPE ROUNDUP. July 27 30, 2017 COMMERICAL EXHIBITORS APPLICATION

RULES AND REGULATIONS. Binding Rules and Regulations of the Website: Rules and Regulations ).

Commercial Cannabis Business: Permit Application FAQs (04/05/18) Page 1 of 6

DOCUMENT A ( ) OVER-ALL DOCUMENTS DATE: THE PLAINVILLE CAMP GROUNDS ASSOCIATION, INC.

73 rd MAAO Educational Conference June 18 th 21 st 2013

The Deposit Protection Service Deposit Protection Custodial Scheme Terms and Conditions

GUIDE TO SELECTING A HOUSING ASSIGNMENT FOR

WHISTLER VACATION CLUB AT TWIN PEAKS GUIDELINES

2017 Parade of Remodeled Homes CONTRACT

1.2. Cooling-off period: the period within which the consumer can make use of his right of withdrawal;

2017 ERIE COUNTY JUDICIAL TAX SALE RULES GOVERNING SALE. By participating in the sale, you agree to be bound by these Rules:

University of Hartford --- Housing Agreement (copy available at

FIG WORKING WEEK Athens, Greece May 22-27, 2004 MEETING PROGRAMME

Building and Apartment number

Course Mass Appraisal Practices and Procedures

THE STATE OF NEW HAMPSHIRE SUPREME COURT

MARGARET M. EHMKE ESTATE

Social Media Policy. This policy shall apply to all Municipal departments and/or agencies.

The enclosed packet contains information regarding the 2016 tax sale and our tax sale procedures.

The Art of Developing Policies

GENTRY HOMES, LTD. TIDES AT LAULANI VII, PHASE 14 SALES PROCESS

MEMBER FEES PROPERTY TRANSFER FEE $ One-time fee charged to buyer when property is sold, based on cost of time and documents.

July Relocation Assistance Amounts - July 1, 2017 through June 30, 2018

2018 Parade of New Homes CONTRACT June 14 17, 2018

Hidden Treasures Antiques & Fine Arts - Terms and Conditions of Sale

CONRAD LUFT LAND & WATER RIGHT AUCTION

Township of Leoni Medical Marihuana Facility License Application

CONTENTS. Page 2 INTRODUCTION

The capitalization rate is essential to any analysis through the income

(C) 2004 Professional Real Estate SchoolChapter I Contracts 1

TENANCY APPLICATION FORM

ZONE TEXT AMENDMENT APPLICATION TITLE 12 ZONING, SECTION

Nonresponse in Sample Surveys. Professor Ron Fricker Naval Postgraduate School Monterey, California

Walktober. Welcome October 2014 Welcome to the latest edition of the Getting Gippsland Active Newsletter.

Resident Contact Form

CHISHOLM CROSSING FINE POLICY

Fundamentals of Real Estate APPRAISAL. 10th Edition. William L. Ventolo, Jr. Martha R. Williams, JD

Transcription:

61A Lecture 14 Friday, October 4

Announcements Homework 4 due Tuesday 10/8 @ 11:59pm. Project 2 due Thursday 10/10 @ 11:59pm. Guerrilla Section 2 this Saturday 10/5 & Sunday 10/6 10am-1pm in Soda. Topics: Data abstraction, sequences, and non-local assignment. Please RSVP on Piazza! Guest lecture on Wednesday 10/9, Peter Norvig on Natural Language Processing in Python. No video (except a screencast)! Come to Wheeler. 2

Mutable Functions

A Function with Behavior That Varies Over Time Let's model a bank account that has a balance of $100 Return value: remaining balance >>> withdraw(25) 75 Argument: amount to withdraw Different return value! >>> withdraw(25) 50 >>> withdraw(60) 'Insufficient funds' Second withdrawal of the same amount >>> withdraw(15) 35 Where's this balance stored? >>> withdraw = make_withdraw(100) Within the parent frame of the function! A function has a body and a parent environment 4

Persistent Local State Using Environments A function with a parent frame The parent contains local state All calls to the same function have the same parent Every call changes the balance Example: http://goo.gl/cuc09s 5

Reminder: Local Assignment Assignment binds name(s) to value(s) in the first frame of the current environment Execution rule for assignment statements: 1.Evaluate all expressions right of =, from left to right. 2.Bind the names on the left the resulting values in the first frame of the current environment. Example: http://goo.gl/wxpg5z 6

Non-Local Assignment & Persistent Local State def make_withdraw(balance): """Return a withdraw function with a starting balance.""" def withdraw(amount): nonlocal balance Declare the name "balance" nonlocal at the top of the body of the function in which it is re-assigned if amount > balance: return 'Insufficient funds' balance = balance - amount return balance Re-bind balance in the first non-local frame in which it was bound previously return withdraw (Demo) 7

Non-Local Assignment

The Effect of Nonlocal Statements nonlocal <name>, <name>,... Effect: Future assignments to that name change its pre-existing binding in the first non-local frame of the current environment in which that name is bound. Python Docs: an "enclosing scope" From the Python 3 language reference: Names listed in a nonlocal statement must refer to pre-existing bindings in an enclosing scope. Names listed in a nonlocal statement must not collide with pre-existing bindings in the local scope. http://docs.python.org/release/3.1.3/reference/simple_stmts.html#the-nonlocal-statement http://www.python.org/dev/peps/pep-3104/ 9

The Many Meanings of Assignment Statements x = 2 Status No nonlocal statement "x" is not bound locally No nonlocal statement "x" is bound locally nonlocal x "x" is bound in a non-local frame nonlocal x "x" is not bound in a nonlocal frame nonlocal x "x" is bound in a non-local frame "x" also bound locally Effect Create a new binding from name "x" to object 2 in the first frame of the current environment. Re-bind name "x" to object 2 in the first frame of the current env. Re-bind "x" to 2 in the first non-local frame of the current environment in which it is bound. SyntaxError: no binding for nonlocal 'x' found SyntaxError: name 'x' is parameter and nonlocal 10

Python Particulars Python pre-computes which frame contains each name before executing the body of a function. Therefore, within the body of a function, all instances of a name must refer to the same frame. Local assignment Example: http://goo.gl/bovzc6 11

Mutable Values & Persistent Local State Mutable values can be changed without a nonlocal statement. Mutable value can change Name-value binding cannot change Example: http://goo.gl/y4tyfz 12

Multiple Mutable Functions (Demo)

Sameness and Change As long as we never modify objects, we can regard a compound object to be precisely the totality of its pieces. A rational number is just its numerator and denominator. This view is no longer valid in the presence of change. Now, a compound data object has an "identity" that is something more than the pieces of which it is composed. A bank account is still "the same" bank account even if we change the balance by making a withdrawal. Conversely, we could have two bank accounts that happen to have the same balance, but are different objects. John's Account $10 Steven's Account $10 14

Referential Transparency, Lost Expressions are referentially transparent if substituting an expression with its value does not change the meaning of a program. mul(add(2, mul(4, 6)), add(3, 5)) mul(add(2, 24 ), add(3, 5)) mul( 26, add(3, 5)) Mutation operations violate the condition of referential transparency because they do more than just return a value; they change the environment. (Demo) 15