nerdexam
Python_Institute

PCEP-30-02 · Question #278

What is the expected output of the following code? print(type(+1E10)) print(type(5.0)) print(type('True')) print(type(False))

The correct answer is A. <class 'float'> <class 'float'> <class 'str'> <class 'bool'>. Option A is correct because Python treats any number written in scientific notation (like 1E10) as a float, regardless of the leading + sign - the result has no decimal point visually, but it's still a floating-point value. 5.0 is unambiguously a float, 'True' is a str because…

Question

What is the expected output of the following code? print(type(+1E10)) print(type(5.0)) print(type('True')) print(type(False))

Options

  • A<class 'float'> <class 'float'> <class 'str'> <class 'bool'>
  • B<class 'int'> <class 'float'> <class 'bool'> <class 'bool'>
  • C<class 'int'> <class 'float'> <class 'str'> <class 'bool'>
  • D<class 'float'> <class 'float'> <class 'bool'> <class 'bool'>

How the community answered

(46 responses)
  • A
    85% (39)
  • B
    2% (1)
  • C
    4% (2)
  • D
    9% (4)

Explanation

Option A is correct because Python treats any number written in scientific notation (like 1E10) as a float, regardless of the leading + sign - the result has no decimal point visually, but it's still a floating-point value. 5.0 is unambiguously a float, 'True' is a str because the quotes make it a string literal rather than a boolean, and False (capital F, no quotes) is Python's built-in boolean literal, giving bool.

Why the distractors fail:

  • B and C both claim +1E10 is int, but scientific notation always produces a float in Python - you can verify with type(1E0).
  • D claims 'True' is bool, but quotes always create a str; only the bare keywords True and False (no quotes) produce a bool.

Memory tip: Use the phrase "Quotes kill the bool" - any value wrapped in quotes is a str, no matter how boolean-looking it is. And remember "E means float" - scientific notation (E or e) always produces a float, never an int.

Community Discussion

No community discussion yet for this question.

Full PCEP-30-02 Practice