Certified Associate in Python Programming (PCAP) — Question 84

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

Answer options

Correct answer: B, D

Explanation

The variable 'string' is assigned the value 'Y' after reversing 'SKY', making string[0] and string[-1] both equal to 'Y', which confirms that option B is true. Additionally, since 'string' is now 'Y', its length is 1, validating option D. Option A is incorrect as string[0] is 'Y', not equal to 'Y', and option C is false because 'string' is not None.