UC Berkeley EECS Head TA Michael Ball The Beauty and Joy of Computing Beyond Blocks Python Session 2: Data Structures UC Berkeley EECS TA Peter Sujan (thanks.

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming Lecture 5 Array and Collections.
Advertisements

Container Types in Python
Computer Science 112 Fundamentals of Programming II Overview of Collections.
I210 review Fall 2011, IUB. Python is High-level programming –High-level versus machine language Interpreted Language –Interpreted versus compiled 2.
The Beauty and Joy of Computing Lecture #18 Besides Blocks I: Intro to Python Amazon Dash is Not an April Fools Joke UC Berkeley EECS Head TA Michael Ball.
CS 106 Introduction to Computer Science I 03 / 17 / 2008 Instructor: Michael Eckmann.
Introduction to Python (for C++ programmers). Background Information History – created in December 1989 by Guido van Rossum Interpreted Dynamically-typed.
Programming 101 with Python: an open-source, cross-platform, and fun language By J. Burton Browning, Ed.D. Copyright © J. Burton Browning All rights reserved.
COMPUTER SCIENCE FEBRUARY 2011 Lists in Python. Introduction to Lists Lists (aka arrays): an ordered set of elements  A compound data type, like strings.
October 4, 2005ICP: Chapter 4: For Loops, Strings, and Tuples 1 Introduction to Computer Programming Chapter 4: For Loops, Strings, and Tuples Michael.
Data Structures in Python By: Christopher Todd. Lists in Python A list is a group of comma-separated values between square brackets. A list is a group.
Introduction to Python By Neil Cook Twitter: njcuk Slides/Notes:
Introduction to Programming Workshop 2 PHYS1101 Discovery Skills in Physics Dr. Nigel Dipper Room 125d
CS 106 Introduction to Computer Science I 03 / 19 / 2007 Instructor: Michael Eckmann.
© Copyright 2012 by Pearson Education, Inc. All Rights Reserved. Chapter 14 Tuples, Sets, and Dictionaries 1.
CompSci Today’s topics Java Review Just a bunch of headings meant to trigger questions A contraction of previous notes Upcoming Midterm Exam Reading.
5-Aug-2002cse Arrays © 2002 University of Washington1 Arrays CSE 142, Summer 2002 Computer Programming 1
Built-in Data Structures in Python An Introduction.
Introducing Python CS 4320, SPRING Resources We will be following the Python tutorialPython tutorial These notes will cover the following sections.
Data Collections: Lists CSC 161: The Art of Programming Prof. Henry Kautz 11/2/2009.
Computer Programming for Biologists Class 3 Nov 13 th, 2014 Karsten Hokamp
Python Primer 1: Types and Operators © 2013 Goodrich, Tamassia, Goldwasser1Python Primer.
OCR GCSE Computing © Hodder Education 2013 Slide 1 OCR GCSE Computing Python programming 1: Introduction.
CS2910 Week 2, Class 1 Today Data Encoding, Part 1 Parsing Data Python Muddiest Point Lab 2 – Bring text In Class, Thursday: Quiz Week 6, Monday: Midterm.
1 CSC 221: Introduction to Programming Fall 2011 Lists  lists as sequences  list operations +, *, len, indexing, slicing, for-in, in  example: dice.
Introduction to Strings Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg 1.
By Austin Laudenslager AN INTRODUCTION TO PYTHON.
GE3M25: Computer Programming for Biologists Python, Class 5
1 CSC 221: Introduction to Programming Fall 2012 Lists  lists as sequences  list operations +, *, len, indexing, slicing, for-in, in  example: dice.
14. DICTIONARIES AND SETS Rocky K. C. Chang 17 November 2014 (Based on from Charles Dierbach, Introduction to Computer Science Using Python and Punch and.
Trinity College Dublin, The University of Dublin GE3M25: Computer Programming for Biologists Python, Class 4 Karsten Hokamp, PhD Genetics TCD, 01/12/2015.
Creating Animations, Working with Graphics, and Accessing Data Lesson 9.
CS190/295 Programming in Python for Life Sciences: Lecture 6 Instructor: Xiaohui Xie University of California, Irvine.
Python Programing: An Introduction to Computer Science
CS10 The Beauty and Joy of Computing Lecture #20 Pyhton II UC Berkeley EECS Lecturer Gerald.
Strings CSE 1310 – Introduction to Computers and Programming Alexandra Stefan University of Texas at Arlington 1.
Dictionaries and File I/O George Mason University.
Lecture 9:FXML and Useful Java Collections Michael Hsu CSULA.
Quiz 3 Topics Functions – using and writing. Lists: –operators used with lists. –keywords used with lists. –BIF’s used with lists. –list methods. Loops.
Today… Files from the Web! Dictionaries. Lists of lists. Winter 2016CISC101 - Prof. McLeod1.
Algorithmic complexity: Speed of algorithms
Tuples and Lists.
Intro to CS Sept 22/23, 2015.
CISC101 Reminders Quiz 2 this week.
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Introduction to Strings
Introduction to Strings
CHAPTER THREE Sequences.
CMSC201 Computer Science I for Majors Lecture 12 – Tuples
CISC101 Reminders Quiz 2 this week.
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Python Tutorial for C Programmer Boontee Kruatrachue Kritawan Siriboon
Algorithmic complexity: Speed of algorithms
Winter 2019 CISC101 2/17/2019 CISC101 Reminders
Python Primer 1: Types and Operators
Introduction to Strings
6. Dictionaries and sets Rocky K. C. Chang 18 October 2018
CS1110 Today: collections.
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Intro to Computer Science CS1510 Dr. Sarah Diesburg
CISC101 Reminders Assignment 2 due today.
Algorithmic complexity: Speed of algorithms
Introduction to Computer Science
Introduction to Strings
Introduction to Strings
Intro to Computer Science CS1510 Dr. Sarah Diesburg
CMPT 120 Lecture 10 – Unit 2 – Cryptography and Encryption –
CMPT 120 Lecture 18 – Unit 3 – Graphics and Animation
CMPT 120 Lecture 26 – Unit 5 – Internet and Big Data
Introduction to Computer Science
Presentation transcript:

UC Berkeley EECS Head TA Michael Ball The Beauty and Joy of Computing Beyond Blocks Python Session 2: Data Structures UC Berkeley EECS TA Peter Sujan (thanks to Glenn Sugden for the first version of these slides)Glenn Sugden is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.mons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

UC Berkeley “The Beauty and Joy of Computing” : Besides Blocks Python Section 2 (2) Garcia  Review (and some new introductions)  Sequences  Operators  Sets  Operators  Dictionaries  Higher-Order Functions  Let’s Re-visit the midterm Exam! Data Structures (Overview)

UC Berkeley “The Beauty and Joy of Computing” : Besides Blocks Python Section 2 (3) Garcia  Typing, Build-In Types  Int, function, string, list, etc  Variables  Looping and Conditionals  for loops,  While loops  Functions  Recursion  This week’s content  Sequences, APIs Review

UC Berkeley “The Beauty and Joy of Computing” : Besides Blocks Python Section 2 (4) Ball Sujan Sequences  Contain an ORDERED set of data  str – short for a “string of text”  list - [‘a’, ‘group’, ‘of’, ‘items’]  range(start, stop, step)  tuple – a list that can’t be modified  Supports very easy iteration:  for item in sequence: print(item)

UC Berkeley “The Beauty and Joy of Computing” : Besides Blocks Python Section 2 (5) Ball Sujan Sequence (General) Operators  elem in & not in sequence  + & *  slice [START:END:STEP]  len()  min() & max()  Even map() filter() & reduce() !  count(item)  Many, many more:

UC Berkeley “The Beauty and Joy of Computing” : Besides Blocks Python Section 2 (6) Ball Sujan Strings and String Operators  Sequence (or “list” or “array”) of chars  Quoting  Single Quotes, Double Quotes  Triple Quotes (this keeps formatting and line breaks)  Concentration, finding length, etc.  help(“string”)  Slicing Supported [START:END:STEP]  #string-methods #string-methods

UC Berkeley “The Beauty and Joy of Computing” : Besides Blocks Python Section 2 (7) Ball Sujan Lists  Collection of any type  Including itself!  Indexing ( list[item] )  Indexed from 0, NOT 1, unlike Snap!  Modifying ( list[ item] = new_item )  Slicing and slicing notation (i.e. [::] )  Exactly the same as string notation!  Operators  append(x), insert(i,x), count(x), sort(), etc.  able-sequence-types able-sequence-types

UC Berkeley “The Beauty and Joy of Computing” : Besides Blocks Python Section 2 (8) Ball Sujan Dictionaries  Very fast access (by key, not number)  “Map” from a key to a value  Syntax  { key1 : value1, key2 : value2, … }  Adding elements  dict[key] = value  Accessing elements; dict[key]  Keys  Looking for specific keys (has_key() & “in”)  Iterating over (iterkeys())

UC Berkeley “The Beauty and Joy of Computing” : Besides Blocks Python Section 2 (9) Ball Sujan API ( Application Programming Interface)  Set of agreements for sharing information  Programming APIs:  “Building Blocks” for common elements such as Open or Save prompts  Web APIs  “Special” URLs for accessing data directly  Example: Open Weather Map API  Map:  Raw data: her?q=Berkeley,CAhttp://api.openweathermap.org/data/2.5/weat her?q=Berkeley,CA

UC Berkeley “The Beauty and Joy of Computing” : Besides Blocks Python Section 2 (10) Ball Sujan Demo (reference)  Code files are all on the website  midterm.py  Some problems from the midterm implemented in Python  fractals.py  Some fractals in Turtle Graphics  ttt.py  Tic-Tac-Toe in Python  Uses the Games Crafters API for getting information about best moves

UC Berkeley “The Beauty and Joy of Computing” : Besides Blocks Python Section 2 (11) Ball Sujan More Information  Sequences & Methods   Coding Bat (Great practice!)   Google’s Python Class  python-class/ python-class/  Exercises (More practice!)  python-class/exercises/basic.html python-class/exercises/basic.html