CS2910 Week 6, Lab Today Dictionaries in Python SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors: Dr. Yoder 1.

Slides:



Advertisements
Similar presentations
Week 9, Class 3: Model-View-Controller Final Project Worth 2 labs Happens-Before ( SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors:
Advertisements

Week 8, Class 3: Model-View-Controller Model-View-Controller Why? What? How? Example: Barnyard Simon for the Web Question: Where should we use the command.
CS2852 Week 8, Class 2 Today Tree terminology Non-Binary and Non-Search Trees Tree Traversals (Remaining slides not yet shown) Tomorrow: Quiz Implementing.
Week 5, Day 3: Observer Today Reducing coupling with the Observer The Observer pattern in Java APIs Posting events to a UI worker thread SE-2811 Slide.
CS 177 Week 11 Recitation Slides 1 1 Dictionaries, Tuples.
SE3910 Week 2, Class 1 Today Basic Circuits Other ??? Tomorrow Lab 2, S365 (Complete prelab BEFORE) Thursday See ScheduleSchedule SE-2811 Slide design:
CS2910 Week 1, Class 3 Today Lab 1 – Additional Assignment Working Ahead Primitives in Java SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder.
SE1011 Week 2, Class 3 Today Compiling and running Another example using Scanner Compile-time and Run-time errors Review for exam SE-1011 Slide design:
CS2852 Week 2, Class 1 Today Generics (Section 051) Big-O runtime analysis Muddiest Point Lab Quiz Includes writing a method from ArrayList class (See.
SE3910 Week 1, Class 3 Today – Introductions Safety Review Policy The course Tomorrow Lab 1, S365 (Purchase Beaglebone black kit BEFORE) Thursday Class.
CS2910 Week 1, Class 2 Today Announce Prof. Michael Vieau’s S-341 6p Thurs Wk 2 Assignment for tomorrow Data Encoding, Part 1 Parsing Data Muddiest Point.
CS2910 Week 1, Class 1 Today Introductions Class/Lab Layout Safety Review - Note about Lab Safety Review Announce Prof. Michael Vieau’s S-341 6p Thurs.
CS-2852 Data Structures Week 5, Class 1 – Testing and Stacks Return Exams & Labs  Package-level access  UML connectors for instance variables Announcement:
CS-2852 Data Structures Week 5, Class 2 – Testing and Stacks Announcement: Lab Demos - 2/3 & 4 on Friday Testing  Definitions, Example  (tentative) Testing.
SE3910 Week 1, Class 2 Today – Introductions Safety Review Policy The course Tomorrow Lab 1, S365 (Purchase Beaglebone black kit BEFORE) Thursday Class.
Today C/C++:.h/.cpp; compiling and linking Fourier Transform (corrected) Nyquist Theorem Audio sampling rates SE-2811 Slide design: Dr. Mark L. Hornick.
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.
CS2852 Week 3, Class 2 Today Stacks Queues SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors: Dr. Yoder 1.
SE1011 Week 6, Class 1 Today Return Half Exam 2 (cont.) Object Oriented Programming (cont.) Muddiest Point Next Half Exam: Week 7, Monday SE-1011 Slide.
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.
SE1011 Week 6, Class 2 Today Return Half Exam 2 (cont.) Object Oriented Programming (cont.) UML class diagrams Muddiest Point Next Half Exam: Week 7, Monday.
CS2910 Week 2, Class 1 Today Return Lab 1 Muddiest Points Quiz Parsing Data in Python SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors:
CS2852 Week 6, Class 1 Today The run-time stack Writing and proving recursive methods SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors:
CS2852 Week 5, Class 2 Today Queue Applications Circular Queue Implementation Testing SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors:
SE1011 Week 3, Class 2 Today Sit down by someone you don't know Learn their name Find out who came farther to get to MSOE at the start of the quarter Designing.
CS2910 Week 7, Lab Today SMTP lab Tuesday (Either today or yesterday) Extra office hour at 11 am (right after lab) Friday Office hour cancelled SE-2811.
CS2910 Week 10, Class 1 Today Modular Arithmetic RSA Week 10, Monday Quiz: Potential topics TCP window size & header format Public/private key encryption.
SE1011 Week 5, Class 1 Today More Java API tools Packages Object Oriented Programming Muddiest Point Tomorrow: Lab 5 – In-lab demo requirements now up.
CS2852 Week 7, Class 1 Today Binary Search Tree Implementing add Implementing find Return Quiz 4 (second attempt) Both sections are graded SE-2811 Slide.
Week 7, Day 3 Half-Exam 2 A New Pattern SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors: Dr. Yoder 1.
CS2852 Week 6, Class 2 Today Class exercise: Implementing a recursive method Binary Search Trees Tomorrow: Quiz at start of lab Implementing a recursive.
CS2910 Week 4, Class 1 Today Encoding in Python – Review Quiz – Encoding in Python Introduction to HTTP SE-2811 Slide design: Dr. Mark L. Hornick Content:
Week 9, Class 3: Java’s Happens-Before Memory Model (Slides used and skipped in class) SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors:
Today Quiz not yet graded Final report requirements posted More on Multithreading Happens-Before in Java SE-2811 Slide design: Dr. Mark L. Hornick Content:
CS2852 Week 3, Class 2 Today Big-O runtime analysis Linked Lists Muddiest Point Lab Quiz Includes writing a method from ArrayList class (See next slide)
CS2852 Week 2, Class 2 Today Big-O runtime analysis Linked Lists Muddiest Point Lab Quiz Includes writing a method from ArrayList class (See next slide)
Week 7, Class 1: The Command Pattern (cont.) Get Ready for Poll Everywhere Labs 2 & 3 returned Lab 7 due this evening at 11pm Quiz tomorrow at start of.
CS2910 Week 4, Class 2 Today Sit by someone you have not yet worked with this quarter. Learn his/her name if unknown. Turn on your laptop and start Wireshark.
CS2910 Week 3, Class 1 Today What is a protocol? Using TCP in Python Defining methods in Python Long procedure design SE-2811 Slide design: Dr. Mark L.
CS2910 Week 8, Class 2 Today Return Quiz Look at Schedule TCP implementation! Week 8, Monday Quiz on SMTP May include some questions requiring you to interpret.
CS2910 Week 7, Class 1 Today Capturing SMTP with Thunderbird Tomorrow Extra office hour at 11 am (right after lab) Friday Office hour cancelled SE-2811.
CS2910 Week 5, Class 1 Today Sit by someone you have not yet worked with Turn on your laptop and start Wireshark. DNS Next week Monday: Midterm Exam SE-2811.
SE1011 Week 7, Class 3 Today Return Half Exam 3 (I have it with me) Object Oriented Programming Details References as arguments Overloaded methods Garbage.
Week 6, Class 3: Composite Swing composites File composites Computer composites SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors:
Week 8, Class 3: Model-View-Controller Final Project Worth 2 labs Cleanup of Ducks Reducing coupling Finishing FactoryMethod Cleanup of Singleton SE-2811.
Week 4, Day 1: Singleton(s?) Singleton leftover Why singletons? How to make lazy initialization work multi- threaded? Observers Why observers? Class structure.
Week 5, Class 3: Decorators Lab questions? Example: Starbuzz coffee Basic Pattern More examples Design Principles Compare with alternatives SE-2811 Slide.
SE3910 Week 8, Class 2 Week 4 Lab: Please return your graded Lab 4 to me so I can enter it in my gradebook Week 7, Class 2 (Wednesday) Half-Exam 2 Done.
CS2911 Week 6, Lab Today Quiz 3 Review Muddiest Point Finish Lab 6 Start Lab 7 Muddiest Point This week, Lab: Quiz at start of lab Week 7, Monday: Half-Exam.
Slide style: Dr. Hornick
SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder
CS2911 Week 6, Class 1 Today Map (dict) objects in Python
Week 2, Day 1: The Factory Method Pattern
CS2911 Week 6, Class 1 Today This week, Lab: Quiz at start of lab
Slide design: Dr. Mark L. Hornick
CS2911 Week 6, Class 1 Today Map (dict) objects in Python
Slide design: Dr. Mark L. Hornick
Week 7, Class 1: The Command Pattern (cont.)
6. Dictionaries and sets Rocky K. C. Chang 18 October 2018
SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder
SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder
Polling vs. Interrupts CS2852 4/9/2019
Slide design: Dr. Mark L. Hornick
CS2911 Week 6, Class 1 Today Map (dict) objects in Python
CS2911 Week 2, Class 3 Today Return Lab 2 and Quiz 1
Slide design: Dr. Mark L. Hornick
Week 8, Class 3: Model-View-Controller
Slide design: Dr. Mark L. Hornick
SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder
Slide design: Dr. Mark L. Hornick
Presentation transcript:

CS2910 Week 6, Lab Today Dictionaries in Python SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors: Dr. Yoder 1

Introduction to Python Python ages = dict() OR ages = {} ages["Nancy"] = 5 ages["Bob"] = 10 print "B:",ages["Bob"] for item in ages.items(): print item[0]+": "+str(item[1]) Java Map ages = new HashMap<>(); ages.put("Nancy", 5); ages.put("Bob", 10); S.o.pl("B: "+ages.get("Bob")); for(Map.Entry e: ages.entrySet()) { S.o.pl(e.getKey()+": " +e.getValue()); } SE-2811 Dr. Yoder 2

Dictionaries A Python Dictionary is like a Map in Java You can use an object as an "index" for an item. The index object is called a "key" and the object stored is called a "value" You can use any object – they don't have to be integers, and they aren't stored sequentially in memory You can iterate through all the entries in a dictionary, or look up an item by its key SE-2811 Dr. Yoder 3

Some important methods items() returns a list of all keys and values, where each item is a tuple holding (key, value) keys() returns a list of all keys values() returns a list of all values has_key(k) returns true if the value is stored in the list SE-2811 Dr.Yoder 4