I have these Python Programming Questions Assumethatthevariabledatareferstothedi
ID: 3700887 • Letter: I
Question
I have these Python Programming Questions
Assumethatthevariabledatareferstothedictionary{“b”:20, “a”:35}.
Write the values of the following expressions:
a data[“a”]
b data.get(“c”, None)
c len(data)
d data.keys()
e data.values()
f data.pop(“b”)
g data
6.1.1
BI Homewerk-201805-32- Hame | Chegg.com x BookshefOnline: Funda CSecure https//booksholf.vitalsource.com//hooks/9781133715283/cfi/211/4/4@0.00:45.8 ::: Apps D Plans Millen con D Welcome-https ear sokans N Lambda Academyo D Mavis Beacon Teac @ Hame Rob Enterc Dawnload the Micro Southwestern Caileg break had to request a cer Other bookmark Ch 5: Lists and Dicti... 5.4 Exercises Go to Ch 5: Lists and Dictiona 1 Give three examples of real-world objects that behave like a dictionary. 2 Assume that the variable data refers to the dictionary ("b" 20, "a" 135) 160 5.1: Lists Write the values of the following expressions: a data[ "a"] 175 5.2:Defining Simple Functions 5.3: Case Study: Generating Sentences 179 b data.get(c", None) C len (data) d data.keys() e data.values() 83 5.4: Dictionaries 5.5:Case Study: Nondirective Psychotherapy f data.pop( "b") 191 g data After the pop above 95 Summary 3 Assume that the variable data refers to the dictionary "b":20, a":35) Write the expressions that perform the following tasks: a Replace the value at the key "b" in data with that value's negation. b Add the key/value pair "c":40 to data. c Remove the value at key "b" in data, safely. d Print the keys in data in alphabetical order 196 Review Questions 198 Projects 1901 CHAPTER 5 Lists and Dictionaries Cr ye ht 2011 Cengage Leuni All Rights Reserved. Muy soc te co ie4, scan eL of diaplicaled in whole ot in L Due to electraie f hs, some thi d party ostett may be suppressed from Ednonai renew has eeme that amy suppressed content des not manly affect the overa leaming esperenn ngape Leaming reserves the ng t to?nove a monal ?tent at any time if sub eBook ? er eOa ter? equmt nghts nestnenons m autre it. 3:33 AM @ ^ 40) 4/5/2018Explanation / Answer
Answers to your queries:
a) data["a"] returns the value assigned to the key "a" which is: 35
b) data.get(“c”, None) returns the value assigned to the key "c" if it is in the dictionary, otherwise returns "None". so for this case, since there is no key named "c", the output will be: None
c) len(data) returns the length of the dictionary: 2
d) data.keys() returns the keys in the dictionary, so the output will be: data(["b", "a"])
e) data.values() returns the values in the dictionary, so the output will be: data([20, 35])
f) data.pop(“b”) returns the value of the key "b" and removes "b" from the dictionary. Output : 20
g) data returns the dictionary as it is. Since we are only left with one element "a", the output will be: {"a": 35}
6.1.1) Given below are the five reasons to use functions over writing basic operators. I hope this helps.