Certified Associate in Python Programming (PCAP) — Question 79
Assuming that the snippet below has been executed successfully, which of the following expressions evaluate to True? (Choose two.) string = 'python'[::2] string = string[-1] + string[-2]
Answer options
- A. string[0] == 'o'
- B. string is None
- C. len(string) == 3
- D. string[0] == string [-1]
Correct answer: A
Explanation
The correct answer is A because the string variable will evaluate to 'on', making string[0] equal to 'o'. Option B is incorrect as the string variable is not None; option C is wrong because the length of 'on' is 2, not 3; and option D is incorrect since string[0] ('o') is not equal to string[-1] ('n').