Assuming that the following snippet has been successfully executed, which of the equations are False? (Choose two.)
Assuming that the following snippet has been successfully executed, which of the equations are False? (Choose two.)
AB
In question, he asked for False equations. so Ans: C and D. because A and B are True
these two are false: C. a [0]== b [0] D. b [0] - 1 ==a [0]
why are answers given incorrect? was asking for false, instead trues were given (?)
C & D are the correct answers
AB is true, but the question asks for the False ones, so: CD When you have an array in a variable and set it to another variable, they share the same id: a = [1] b = a print(id(a), id(b)) #same id BUT, unlike the previous question, when you do this: a = [1] b = a[:] # [start:stop:step] b has now a different id, that means it is a different array
After executing the snippet: a = a[0] = 1 b = b[0] = 0
answer should be C and D, it's asking for False not True
False are C & D
>>> len(a)==len(b) True >>> a [0]-1 ==b[0] True >>> a [0]== b [0] False >>> b [0] - 1 ==a [0] False
Should be C, D.
ask about false ones
These answers are wrong, c and d are right
Correct Answer should be C and D as the question says which equations are False
a=[0] b=a[:] a[0]=1 print(len(a) == len(b)) --> True print(a[0] - 1 == b[0]) --> True print(a[0] == b[0]) --> False print(b[0] - 1 == a[0]) --> False My answer is C and D
Correct Answer should be C and D as the question says which equations are False a = [0] b = a[:] a[0] = 1 a[0] # is 1 b[0] # is 0 so: print(len(a) == len(b)) # => True print(a[0] - 1 == b[0]) # => True print(a[0] == b[0]) # => False print(b[0] - 1 == a[0]) # => False
C and D
Lists [] are always mutable Tuples () are always immutable Therefore a and b will not stay the same as they are both lists compared to the previous question.