PCAP Exam QuestionsBrowse all questions from this exam

PCAP 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:

Show Answer
Correct Answer: BC

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

5 comments
Sign in to comment
smarty_arse
Jan 21, 2022

Answer is correct

zwakenberg
Nov 29, 2021

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
Dec 4, 2021

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

macxszOptions: AC
May 3, 2022

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

666_mOptions: AC
May 7, 2022

AC is correct.

ArulkumarOptions: BC
Apr 15, 2023

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