Which line can be used instead of the comment to cause the snippet to produce the following expected output? (Choose two.)
Expected output:
1 2 3
Code:
Which line can be used instead of the comment to cause the snippet to produce the following expected output? (Choose two.)
Expected output:
1 2 3
Code:
To produce the expected output '1 2 3', the first element in the tuple must be assigned to 'a', the second to 'b', and the third to 'c'. The line 'a, b, c = c, b, a' correctly assigns these values: 'a' gets the value of 'c' (1), 'b' remains 2, and 'c' gets the value of 'a' (3). The line 'a, b, c = c, a, b' similarly rearranges values such that 'a' gets the value of 'c' (1), 'b' gets 'a' (2), and 'c' gets 'b' (3). Therefore, the correct answers are 'a, b, c = c, b, a' and 'a, b, c = c, a, b'.
Answer is correct
All of them are wrong. c, b, a = b, a, c gives 1 3 2 c, b, a = a, c, b gives 2 1 3 a, b, c = c, a, b gives 1 3 2 a, b, c = a, b, c gives 3 2 1 The correct answer should be something like this a, b, c = c, b, a which gives 1 2 3
A & C are correct. The variables on the right of '=' are the original values and the variables on the left are the new values.
Ans : C c,b,a=1,3,2 a,b,c=c,a,b print(a,b,c)
AC is correct.
A. c, b, a = b, a, c C. a, b, c = c, a, b