Thursday , September 19 2024

What is the output of the following snippet? dd = {“1”: “0”, “0”: “1”} for x in dd.vals(): print(x, end=””)

Questions BankCategory: Python Essentials 1What is the output of the following snippet? dd = {“1”: “0”, “0”: “1”} for x in dd.vals(): print(x, end=””)
What is the output of the following snippet?

dd = {"1": "0", "0": "1"}
for x in dd.vals():
    print(x, end="")
  • 0 1
  • the code is erroneous (the dict object has no vals() method)
  • 0 0
  • 1 0

Explanation: The following snippet will raise the AttributeError exception, because the dict object has no attribute named vals. Replacing vals with values should do the job.

More Questions: Python Essentials 1 (PE1) Course Final Test