Certified Associate in Python Programming (PCAP-31-03) — Question 17

Assuming that the snippet below has been executed successfully, which of the following expressions will evaluate to True? (Choose two.) string = 'python'[::2] string = string[-1] + string[-2]

Answer options

Correct answer: A, B

Explanation

The correct answers A and B are true because after executing the snippet, 'string' becomes 'on' (length 2), and the first character is 'o'. Option C is incorrect as 'string[0]' is 'o', which is not equal to 'n' (string[-1]). Option D is false because 'string' holds a value, not None.