Exam PCAP All QuestionsBrowse all questions from this exam
Question 45

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:

    Correct Answer: B, C

    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'.

Discussion
smarty_arse

Answer is correct

zwakenberg

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

techdawgs

A & C are correct. The variables on the right of '=' are the original values and the variables on the left are the new values.

ArulkumarOptions: BC

Ans : C c,b,a=1,3,2 a,b,c=c,a,b print(a,b,c)

666_mOptions: AC

AC is correct.

macxszOptions: AC

A. c, b, a = b, a, c C. a, b, c = c, a, b