ITP Chapter 12, 17

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

dict-3-8: What is printed by the following statements? mydict = {"cat":12, "dog":6, "elephant":23, "bear":20} answer = mydict.get("cat") // mydict.get("dog") print(answer) A. 2 B. 0.5 C. bear D. Error, divide is not a valid operation on dictionaries.

A

dict-3-9: What is printed by the following statements? mydict = {"cat":12, "dog":6, "elephant":23, "bear":20} print("dog" in mydict) A. True B. False

A

dict-1-5: A dictionary is an unordered collection of key-value pairs. A. False B. True

B

dict-1-6: What is printed by the following statements? mydict = {"cat":12, "dog":6, "elephant":23} print(mydict["dog"]) A. 12 B. 6 C. 23 D. Error, you cannot use the index operator with a dictionary.

B

dict-3-10: What is printed by the following statements? mydict = {"cat":12, "dog":6, "elephant":23, "bear":20} print(23 in mydict) A. True B. False

B

dict-3-11: What is printed by the following statements? total = 0 mydict = {"cat":12, "dog":6, "elephant":23, "bear":20} for akey in mydict: if len(akey) > 3: total = total + mydict[akey] print(total) A. 18 B. 43 C. 0 D. 61

B

Q-4: What is the the output of the following print code? class Car: def __init__(self): self.color = "Red" self.size = "Big" BMW = Car() Tesla = Car() x = BMW is Tesla y = type(BMW)==type(Tesla) print(x, y) A. True True B. True False C. False True D. False False

C

dict-2-4: What is printed by the following statements? mydict = {"cat":12, "dog":6, "elephant":23} mydict["mouse"] = mydict["cat"] + mydict["dog"] print(mydict["mouse"]) A. 12 B. 0 C. 18 D. Error, there is no entry with mouse as the key.

C

dict-3-7: What is printed by the following statements? mydict = {"cat":12, "dog":6, "elephant":23, "bear":20} keylist = list(mydict.keys()) keylist.sort() print(keylist[3]) A. cat B. dog C. elephant D. bear

C

dict-4-2: What is printed by the following statements? mydict = {"cat":12, "dog":6, "elephant":23, "bear":20} yourdict = mydict yourdict["elephant"] = 999 print(mydict["elephant"]) A. 23 B. None C. 999 D. Error, there are two different keys named elephant.

C


Kaugnay na mga set ng pag-aaral

TLB-Chapter 32: Skin Integrity and Wound Care

View Set

Ethical Issues in Clinical Research, Principles of Measurement, Concepts of Measurement Reliability, Concepts of Measurement Validity, Evidence-Based Practice, Sampling and Validity in Experimental Designs, Principles of Clinical Trials, Quasi-Experi...

View Set

Ohio Health & Life Insurance Exam Final

View Set