Exam PCAP-31-03 All QuestionsBrowse all questions from this exam
Question 14

What is the expected behavior of the following code?

    Correct Answer: A

    The code converts the result of 1/3 to a string, which usually evaluates to '0.3333333333333333'. It then iterates over each character in this string, constructing a new string 'dummy' that is the same as 'string'. Finally, it prints the last character of 'dummy', which corresponds to the last character in the string representation of 1/3. Therefore, the output is '3'.

Discussion
Dave304409Option: A

A is correct

kstrOption: A

Correct answer is A string = str(1/3) dummy = '' for character in string: dummy = dummy + character print (dummy [-1])

DKAT2023Option: A

A is correct