Reading (Due: Mon, Oct. 25)

1y ago
12 Views
3 Downloads
217.00 KB
19 Pages
Last View : 2m ago
Last Download : 2m ago
Upload by : Tripp Mcmullen
Transcription

COMP 110: Lecture 22 News & Notes:ØOffice hours @ 3:30PMØMidterm Re-dos due Tuesday @ 10PMØPSA #5 due Wednesday Reading (Due: Mon, Oct. 25):ØRA16: Sections 8.1 – 8.6

Group DiscussionIn what ways are dictionaries similar to lists inPython? How are they different?

KQS Results Summary KeepØClicker questions and class participation QuitØReference DiagramsØLabs (spend all time on PSAs) StartØReference DiagramsØPut answers on posted lecture slides

Chapter 12DICTIONARIES

Dictionaries allow us to create associationsbetween objects. merriam { "foo" : 10, "bar": 33 } merriam["foo"]10 merriam["baz"] 18 merriam{'foo' : 10, 'bar': 33, 'baz': 18 } "foo" in merriam, "woof" in merriam(True, False) 33 in merriamFalse merriam["woof"]KeyError: 'woof'

How many of the following would you usea dictionary for rather than a list?1. Keeping track of all the types of birds you seewhile out bird watching.2. Keeping track of how many of each type ofbird you see.3. Keeping track of the cost of various items onyour grocery list.4. Keeping track of which actor/actress playedeach part in a movie.A. 0B. 1C. 2D. 3E. 4

How many of the following would you usea dictionary for rather than a list?1. Keeping track of all the types of birds you seewhile out bird watching.2. Keeping track of how many of each type ofbird you see.3. Keeping track of the cost of various items onyour grocery list.4. Keeping track of which actor/actress playedeach part in a movie.A. 0B. 1C. 2D. 3E. 4

How many of the following statements willcause a KeyError?webster {"meow" : 10, "bark": 33}I.II.III.IV.V.webster['baa'] 25webster["bark"] 22webster['oink'] webster["oink"] 1webster["bark"] webster['bark'] 1webster["bark"] webster["moo"] 1A.B.C.D.E.12345

How many of the following statements willcause a KeyError?webster {"meow" : 10, "bark": 33}I.II.III.IV.V.webster['baa'] 25webster["bark"] 22webster['oink'] webster["oink"] 1webster["bark"] webster['bark'] 1webster["bark"] webster["moo"] 1A.B.C.D.E.12345

What is printed while executing thefollowing code?def anon(my str):oxford {} # empty dictionaryfor ch in "ABCDE":oxford[ch] 0for ch in my str:oxford[ch] oxford[ch] 1return oxfordx r

What is printed while executing thefollowing code?def anon(my str):oxford {} # empty dictionaryfor ch in "ABCDE":oxford[ch] 0for ch in my str:oxford[ch] oxford[ch] 1return oxfordx r

What is printed while executing thefollowing code?def anon(my str):oxford {} # empty dictionaryfor ch in "ABCDE":oxford[ch] 0for ch in my str:oxford[ch] oxford[ch] 1return oxfordx r

What is printed while executing thefollowing code?def anon(my str):oxford {} # empty dictionaryfor ch in "ABCDE":oxford[ch] 0for ch in my str:oxford[ch] oxford[ch] 1return oxfordx r

@Home: What is printed while executingthe following code?def anon(my str):oxford {} # empty dictionaryfor ch in "ABCDE":oxford[ch] 0for ch in my str:oxford[ch] oxford[ch] 1return oxfordx )print(list(x.values()))

What does the anon function do?def anon(my str):oxford {} # empty dictionaryfor ch in "ABCDE":oxford[ch] 0for ch in my str:oxford[ch] oxford[ch] 1return oxfordA. Counts the number of characters in my str.B. Counts how many times a specific characteroccurs.C. Finds the index where a character occurs.D. None of the above.

What does the anon function do?def anon(my str):oxford {} # empty dictionaryfor ch in "ABCDE":oxford[ch] 0for ch in my str:oxford[ch] oxford[ch] 1return oxfordA. Counts the number of characters in my str.B. Counts how many times a specific characteroccurs.C. Finds the index where a character occurs.D. None of the above.

Which values of XXX and YYY will cause aKeyError in the program?def anon(my str):oxford {} # empty dictionaryfor ch in "ABCDE":oxford[ch] 0for ch in my str:oxford[ch] oxford[ch] 1return oxfordx anon(XXX)print(x[YYY])XXXYYYA. "AB""C"B.C.D.E."A""G""""GAB"Two of the above.None of the above.

Which values of XXX and YYY will cause aKeyError in the program?def anon(my str):oxford {} # empty dictionaryfor ch in "ABCDE":oxford[ch] 0for ch in my str:oxford[ch] oxford[ch] 1return oxfordx anon(XXX)print(x[YYY])XXXYYYA. "AB""C"B.C.D.E."A""G""""GAB"Two of the above.None of the above.

We can use pyplot’s bar function to help usvisualize the output of anon. import matplotlib.pyplot as ppimport comp110freqs comp110.anon("AEABECAC")pp.bar(freqs.keys(), freqs.values())pp.xlabel("Answer")pp.ylabel("# Responses")pp.title("Poll Results")pp.show()Poll resultsAssume anon is defined incomp110.py.

D. 3 E. 4 1. Keeping track of all the types of birds you see while out bird watching. 2. Keeping track of how many of each type of bird you see. 3. Keeping track of the cost of various items on your grocery list. 4. Keeping track of which actor/actress played each part in a movie.

Related Documents:

5. la fille de mon grand-père 6. le fils de ma mère 7. la fille de mon fils 8. le fils de ma belle-mère a. mon grand-père f. mon demi-frère b. ma sœur g. mon oncle c. ma tante h. ma petite-fille d. mon cousin i. mon frère e. mon neveu 3 Choisissez Fill in the blank by selecting the most appropriate answer. 1. Voici le frère de mon père.

5073 pageland sc mon,wed, fri wed, fri sun 6042 pauls valley ok mon, fri fri, tue 6047 bedford pa mon,wed, fri thur, sun, mon 6055 monroe ga mon,wed, fri wed, fri sun 6056 terrell tx mon, fri fri, tue 6057 robert/hammond la mon, fri thur, mon 6059 olney il mon,wed, fri thu

JEREMY 4 Tarragon Theatre: COTTAGERS AND INDIANS OCTOBER SEPTEMBER DECEMBER NOVEMBER OCT 5 OCT 12 OCT 14 OCT GARAGE SALE – 21 OCT 26 OCT 27 OCT 19 OCT 16 OCT 13 OCT 14 25 OCT 26 OCT 21 OCT 17 OCT 11 . GIRLS NITE OUT CHRIS GIBBS: Like Father, Like Son? Sorry BOX OFFICE 905-681

10 Oct 19 Bora Bora, French Polynesia 8:00 18:00 11 Oct 19 Tahiti (Papeete), French Polynesia 7:00 17:00 12 Oct 19 Day at Sea - - 13 Oct 19 Day at Sea - - 14 Oct 19 Pago Pago, American Samoa 8:00 17:00 15 Oct 19 Day at Sea - - 16 Oct 19 Day at Sea (Cross International Date Line) - - 18 Oct 19 Day at Sea - - 19 Oct 19 Auckland, New Zealand 7:00 .

CONTI STOCKHOLM 0AB7LS1MA 26-Sep 28-Sep WIELAND 0WWABW1MA 5-Oct 28-Oct 29-Oct 1-Nov 20-Nov SHIJING 04IA6E1MA 3-Oct 5-Oct HANS SCHULTE 0WWADW1MA 12-Oct 4-Nov 5-Nov 8-Nov 27-Nov EMC TBN 4 04IA8E1MA 10-Oct 12-Oct CMA CGM DUTCH HARBOR 0WWAFW1MA 19-Oct 11-Nov 12-Nov 15-Nov 4-Dec

Best Bargain Tator Bucks, Potato Triangles & Sideliners 199 32-Oz. Pkg. White or Whole Grain Village Hearth Bread 178 . RETAILERS RETURN COUPON BY: 10/31/16 FALL COUPON CLIPPER Week FOUR of Super Coupon Savings! Plus HOT Non-Coupon Items! SUN OCT 16 MON OCT 17 TUES OCT 18 WED OCT 19 THURS OCT 20 FRI OCT 21 SAT OCT 22

All About the Alphabet Reading Alphabet Fun: A Reading Alphabet Fun: B Reading Alphabet Fun: C Reading Alphabet Fun: D Reading Alphabet Fun: E Reading Alphabet Fun: F Reading Alphabet Fun: G Reading Alphabet Fun: H Reading Alphabet Fun: I Reading Alphabet Fun: J Reading Alphabet Fun: K Reading Alphabet Fu

Bursa Agriculture 2017 15th Agriculture, Seed Raising, Sapling And Dairy Industry Fair Bursa Oct 10-13, 2017 Agriculture and Farming Oct 10: Arrival, Oct 11: Visit to the Fair, Oct 12: B2Bs, Oct 13: Departure 10. İstanbul Fashion Conference İstanbul Oct 11-12, 2017 Fashion Oct 10: Arrival, Oct 11: Participation to Congress-