PCEP-30-02 · Question #283
What is the expected output of the following code? print ('oat ('*1.3))
The correct answer is D. 1.3. The question appears to have a formatting/OCR issue - the code print ('oat ('*1.3)) is likely a garbled rendering of print(float(1.3)). With that interpretation, option D is correct because float(1.3) simply converts 1.3 to a floating-point value (which it already is), so…
Question
Options
- AThe code is erroneous.
- B1, 3
- C13
- D1.3
How the community answered
(29 responses)- A14% (4)
- B7% (2)
- C10% (3)
- D69% (20)
Explanation
The question appears to have a formatting/OCR issue - the code print ('oat ('*1.3)) is likely a garbled rendering of print(float(1.3)). With that interpretation, option D is correct because float(1.3) simply converts 1.3 to a floating-point value (which it already is), so print(float(1.3)) outputs exactly 1.3.
Why the distractors are wrong:
- A (erroneous) is wrong because
print(float(1.3))is valid Python -float()accepts a numeric literal with no errors. - B (1, 3) is wrong because Python does not split a float on its decimal point; there is no comma in the output.
- C (13) is wrong because Python never drops the decimal point or concatenates the digits - that would require explicit string manipulation.
Memory tip: Think of float() as a "pass-through" when its argument is already a decimal literal - it returns the value unchanged, so float(1.3) gives you 1.3, not some transformed integer.
Community Discussion
No community discussion yet for this question.