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.
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
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
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
FarukhJamal
Highly Voted 3 years, 2 months agorodanielb
Most Recent 1 year, 3 months agoEllo2023
1 year, 6 months agoAmcal
1 year, 8 months agoivanbicalho
1 year, 9 months agoMherSimonyan
1 year, 9 months agonaveenbv80
1 year, 12 months agoJnanada
2 years, 3 months agoPremJaguar
2 years, 4 months agomacxsz
2 years, 7 months agojapimil
2 years, 7 months agoAlMargoi
2 years, 8 months agorocky48
2 years, 8 months agoKuzymir
2 years, 9 months agoGioGiunta
2 years, 9 months agodiazed
2 years, 10 months agoxsaints
3 years ago