1 / 14

UW CSE 190p Section

UW CSE 190p Section. 7 / 5 , Summer 2012 Dun-Yu Hsiao. Before We Start. Create an empty text file and save everything you try and get in it as a report for today. Include the following in the report file: Your name and your teammate’s name The command scripts you run today

azra
Download Presentation

UW CSE 190p Section

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. UW CSE 190p Section 7/5, Summer 2012 Dun-Yu Hsiao

  2. Before We Start • Create an empty text file and save everything you try and get in it as a report for today. • Include the following in the report file: • Your name and your teammate’s name • The command scripts you run today • Email to TA after class. • As usual, work with your teammate and you are welcomed to ask!

  3. Outlines • List List List! • List comprehension • Function: type(.) • Library: Matplotlib • Library: NetworkX

  4. More on List • Insert/remove • Find in list • in • Index

  5. List Comprehension >>> squares = [] >>> for x in range(10): squares.append(x**2) >>> squares [0, 1, 4, 9, 16, 25, 36, 49, 64, 81] squares = [x**2 for x in range(10)]

  6. [(x, y) for x in [1,2,3] for y in [3,1,4] if x != y] combs = [] for x in [1,2,3]: for y in [3,1,4]: if x != y: combs.append((x, y))

  7. List Comprehension • To construct lists in a very natural, easy way • S = {x² : x in {0 ... 9}} • V = (1, 2, 4, 8, ..., 2¹²) • M = {x | x in S and x even}

  8. S = [x**2 for x in range(10)] • V = [2**i for i in range(13)] • M = [x for x in S if x % 2 == 0]

  9. [j for i in range(2, 8) for j in range(i*2, 50, i)][j for i in range(2, 8) for j in range(i*2, 50, i)]

  10. Function: type(.) • When in doubt with the data type, just check!

  11. Library: Matplotlib • Plot and show • Save • Label and legend

  12. Library NetworkX • Create graph, draw • Add/remove edge • Add/remove node • Node/edge numbers

  13. Homework Questions?

  14. Questions?

More Related