Courseiva

PCEP Practice Question: Data Types, Variables, Basic I/O and Operators

A developer writes a script that records a product price. The line is:

price = 19.99

Later, the script runs print(type(price)). What is displayed?

⚠ Common exam trap

The trap here is thinking a number with few decimal digits might be stored as an integer or a special decimal type rather than a plain float.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

<class 'float'>

Python infers a variable's type from the value assigned to it, and any numeric literal with a decimal point becomes a float. The type function returns the class of the object, and printing that class shows the type name in angle brackets. Since 19.99 includes a decimal point, the output is the float class.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    <class 'int'>

    Why it's wrong here

    This option ignores the decimal point in the literal. A number written without a decimal point, such as 19, would create an int, but 19.99 contains a fractional part, so Python creates a float. The type function would never report int for a value assigned from a literal with a decimal point.

  • ✗

    <class 'decimal'>

    Why it's wrong here

    There is no built-in type named decimal in Python. The standard library does provide a Decimal class in the decimal module, but it must be imported explicitly and instantiated deliberately, and it is not produced by writing an ordinary floating-point literal. A plain assignment like price = 19.99 always yields a float, not a Decimal object.

  • ✓

    <class 'float'>

    Why this is correct

    Any numeric literal containing a decimal point in Python is a float, regardless of how many digits appear after it. Assigning 19.99 to price makes the variable reference a float object, and the built-in type function returns the class object for that type. Printing it displays the class name inside angle brackets, so the script outputs <class 'float'>.

  • ✗

    <class 'str'>

    Why it's wrong here

    A string type would result only if the value were enclosed in quotes, as in price = '19.99'. Because the literal appears with no quotation marks, Python parses it as a numeric value rather than text. The type function therefore reports a numeric class, and str is incorrect for this assignment.

About these practice questions

This PCEP question is part of Courseiva's 482-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Python Institute exam blueprint

This PCEP practice question is part of Courseiva's free Python Institute certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCEP exam.