UW CSE 190p Section 8/2, Summer 2012 Dun-Yu Hsiao.

Slides:



Advertisements
Similar presentations
ThinkPython Ch. 10 CS104 Students o CS104 n Prof. Norman.
Advertisements

Introduction to Programming Lecture 15. In Today’s Lecture Pointers and Arrays Manipulations Pointers and Arrays Manipulations Pointers Expression Pointers.
CHAPTER 4 AND 5 Section06: Sequences. General Description "Normal" variables x = 19  The name "x" is associated with a single value Sequence variables:
© Janice Regan, CMPT 128, February CMPT 128: Introduction to Computing Science for Engineering Students Pointers.
UW CSE 190p Section 7/12, Summer 2012 Dun-Yu Hsiao.
Dictionaries: Keeping track of pairs
DICTIONARIES. The Compound Sequence Data Types All of the compound data types we have studies in detail so far – strings – lists – Tuples They are sequence.
Software Development Method. Assignments Due – Homework 0, Warmup Reading – Chapter 2 –
Identifiers and Assignment Statements. Data structures In any programming language you need to refer to data The simplest way is with the actual data.
COMPUTER SCIENCE FEBRUARY 2011 Lists in Python. Introduction to Lists Lists (aka arrays): an ordered set of elements  A compound data type, like strings.
Presented by: Mojtaba Khezrian. Agenda Object Creation Object Storage More on Arrays Parameter Passing For Each VarArgs Spring 2014Sharif University of.
Values, variables and types © Allan C. Milne v
OCR Computing GCSE © Hodder Education 2013 Slide 1 OCR GCSE Computing Python programming 6: Variables and constants.
EGR 2261 Unit 8 One-dimensional Arrays  Read Malik, pages in Chapter 8.  Homework #8 and Lab #8 due next week.  Quiz next week.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
Peyman Dodangeh Sharif University of Technology Fall 2013.
Data Types and Operators  Two category of data types:  Primitive type: value type. Store values.  Object type: reference type. Store addresses.
Sadegh Aliakbary Sharif University of Technology Spring 2011.
Variables When programming it is often necessary to store a value for use later on in the program. A variable is a label given to a location in memory.
Recap form last time How to do for loops map, filter, reduce Next up: dictionaries.
1 Computer Science of Graphics and Games MONT 105S, Spring 2009 Lecture 17 Parameters, Scope, Return values.
Storage Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
UW CSE 190p Section 7/26, Summer 2012 Dun-Yu Hsiao.
Lecture 04 – Models of memory Mutable and immutable data.
Cs2220: Engineering Software Class 3: Java Semantics Fall 2010 University of Virginia David Evans.
Functions: Part 2 of /11/10: Lecture 16 CMSC 104, Section 0101 John Y. Park 1.
C Programming Lecture 16 Pointers. Pointers b A pointer is simply a variable that, like other variables, provides a name for a location (address) in memory.
By Austin Laudenslager AN INTRODUCTION TO PYTHON.
Collections Michael Ernst CSE 190p University of Washington.
Number Representation Lecture Topics How are numeric data items actually stored in computer memory? How much space (memory locations) is.
Peyman Dodangeh Sharif University of Technology Spring 2014.
Values, Types, and Variables. Values Data Information Numbers Text Pretty much anything.
CSE 130 : Winter 2009 Programming Languages Lecture 11: What’s in a Name ?
Quiz 3 Topics Functions – using and writing. Lists: –operators used with lists. –keywords used with lists. –BIF’s used with lists. –list methods. Loops.
Dictionaries Ruth Anderson UW CSE 160 Winter
Dictionaries Alexandra Stefan CSE1310 – University of Texas at Arlington.
Objects and Memory Mehdi Einali Advanced Programming in Java 1.
Equality, references and mutability COMPSCI 105 SS 2015 Principles of Computer Science.
Scientific Programming in Python -- Cheat Sheet
Sharing, mutability, and immutability
When to use Tuples instead of Lists
CMSC201 Computer Science I for Majors Lecture 22 – Searching
The Python Data Model UW CSE 190p Summer 2012.
Ruth Anderson CSE 140 University of Washington
Register Use Policy Conventions
Sharing, mutability, and immutability
More Loop Examples Functions and Parameters
Sharing, mutability, and immutability
Sharing, mutability, and immutability
Lecture 18 Arrays and Pointer Arithmetic
Sharing, mutability, and immutability
Ruth Anderson UW CSE 160 Winter 2017
Arrays ICS2O.
References.
Sharing, mutability, and immutability
Michael Ernst CSE 140 University of Washington
Reference semantics, variables and names
(more) Python.
CSC1018F: Intermediate Python (Tutorial)
Ruth Anderson CSE 160 University of Washington
Ruth Anderson UW CSE 160 Spring 2018
CSE 231 Lab 8.
CSE 190p University of Washington Michael Ernst
Winter 2019 CISC101 5/26/2019 CISC101 Reminders
Introduction to Dictionaries
More 2D Array and Loop Examples Functions and Parameters
Dictionary.
Tuple.
Introduction to Computer Science
Ruth Anderson UW CSE 160 Winter 2016
Presentation transcript:

UW CSE 190p Section 8/2, Summer 2012 Dun-Yu Hsiao

Outlines Function: id(.) Mutable and immutable types Quiz walkthrough Homework question

Memory Visualization

Function: id(.) Return the “identity” of an object. Show the address of the object in memory. An integer (or long integer) which is guaranteed to be unique and constant for this object during its lifetime.

Immutability By immutability, we mean that whenever we start manipulating a immutable item, Python will spawn off another value for us.

Immutability Example x = 300 y = 300 s = 'a string' t = ('a', 'tuple')

Mutability For mutable types, we can actually change the value where it's stored in memory.

Mutability Example l = [1, 2, 3]

Mutable and Immutable Types Mutable types: – list, dictionary Immutable types: – Int, float, string, tuple

Quiz Walkthrough Assume these definitions: y = 4 def double(y): return y + y Evaluate the following expression. Show every step. y + double(3 * y)

Quiz Walkthrough y = 3 def double(y): return y + y def quadruple1(y): return double(double(y)) def quadruple2(y): return double(y) + double(y) def quadruple3(y): return y + y + y + y double(y) + quadruple1(double(y) + y)

Quiz Walkthrough y = 3 def double(y): return y + y def quadruple1(y): return double(double(y)) def quadruple2(y): return double(y) + double(y) def quadruple3(y): return y + y + y + y double(y) + quadruple2(double(y) + y)

Quiz Walkthrough y = 3 def double(y): return y + y def quadruple1(y): return double(double(y)) def quadruple2(y): return double(y) + double(y) def quadruple3(y): return y + y + y + y double(y) + quadruple3(double(y) + y)

Homework/Quiz Questions?