Q: What will be the output of the following Python code? x = 123 for i in x: print(i)
Solution: Objects of type int are not iterable.
Q: What will be the output of the following Python code? d = {0, 1, 2} for x in d.values(): print(x)
Solution: Objects of type set have no attribute values.
Q: What will be the output of the following Python code? d = {0, 1, 2} for x in d: print(x)
Solution: Loops over the elements of the set and prints them.
Q: What will be the output of the following Python code? d = {0, 1, 2} for x in d: print(d.add(x))
Solution: Variable x takes the values 0, 1 and 2. set.add() returns None which is printed.
You Have Score    | /4 |