PCEP Practice Question: Data Types, Variables, Basic I/O and Operators
A Python script contains the following code:
price = 19.99 quantity = 3 total = price * quantity
print(type(total))
What is displayed when this script runs?
⚠ Common exam trap
The trap here is assuming that multiplying a decimal literal by a whole number returns an integer merely because the product has no fractional part shown.
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'>
The multiplication of a float and an int in Python produces a float because Python applies numeric type promotion, converting the integer operand to a float before the operation. The variable total therefore holds a float, and type(total) displays the class object for floats. Integer output would require both operands to be int, and string output would require quoted text.
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 'str'>
Why it's wrong here
The str type appears only when values are enclosed in quotes, which is not the case for price or quantity here. Multiplying a number by a number never produces a string in Python; that would require explicit conversion with str() or formatting. This distractor confuses numeric arithmetic with text handling.
- ✗
59.97
Why it's wrong here
Although 59.97 is the numeric product of 19.99 and 3, the script prints type(total), not total itself. type() returns the class object of its argument and displays it in angle brackets. This option ignores the type() call entirely and reports the value instead of the type.
- ✓
<class 'float'>
Why this is correct
In Python, when an int and a float are combined with the multiplication operator, the int is converted to a float and the result is a float. Since price is 19.99, a float, multiplying it by the integer quantity produces a float value, and type() reports the class of that result as float.
- ✗
<class 'int'>
Why it's wrong here
This would be the output only if both operands were integers, because multiplying two int values in Python always yields an int. Here price is a float literal, so the float type is contagious and the product is a float. Assuming integer output ignores how Python promotes mixed numeric types during arithmetic.
Go deeper
Related to this question
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 →
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.