Computer Science, asked by sugnik11sc2020, 3 months ago

Predict the output of the following

>>> a =[2,3,4,6]

>>> b = [2, [3,4],6]

>>> c = [2,3,4,6]

>>> a ==b -- (i)

>>> a == c --(ii)

a) (i) false, (ii) True

b) (i) True, (ii) True

c) (i) False, (ii) False

d) (i) True, (ii) False​

Answers

Answered by Equestriadash
24

Answer:

(a) (i) False, (ii) True

Explanation:

When you take (i), you're comparing list (a) and list (b), i.e., you're comparing [2, 3, 4, 6] and [2, [3, 4], 6].

Even though they may have the same elements, it's still not considered equivalent lists, because (b) has a nested list inside, while (a) doesn't.

For two lists to be equivalent, they need to have the same exact elements and the same exact order.

When you look at list (c), it's the exact copy of list (a). Hence (ii) will give the output True and (i) will result to False.

Similar questions