PCEP Computer Programming and Python Fundamentals Practice Question
Which of the following is a floating-point literal?
⚠ Common exam trap
Candidates often confuse a string containing a number (like `'3.14'`) with an actual numeric literal, or mistake an integer literal for a float, especially when the number looks like a decimal but lacks the decimal point.
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
✓
3.14
`3.14` is a numeric literal with a decimal point, which Python interprets as a floating-point number. Floating-point literals represent real numbers and can be written with a decimal point or using scientific notation (e.g., `3.14e0`).
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
'3.14'
Why it's wrong here
Quotation marks make '3.14' a string literal, not a numeric floating-point literal, so its type is str. It is tempting because the digits look like a decimal fraction, and the same characters unquoted would be the correct answer; the quotes are the deciding factor.
- ✗
42
Why it's wrong here
42 is an integer literal, stored as int with no fractional component, so it is not floating-point. It is tempting because it is a valid numeric literal and would be correct if the question asked for an integer literal rather than a float.
- ✗
1+2j
Why it's wrong here
1+2j is a complex literal, producing a complex number with real and imaginary parts, not a float. It is tempting because it contains a decimal-looking component and is numeric, and would be correct if the question asked for a complex literal instead.
- ✓
3.14
Why this is correct
The decimal point makes 3.14 a floating-point literal, satisfying the stem's requirement for a real-number constant. Python's tokeniser classifies any numeric literal containing a decimal point or exponent as float, so 3.14 evaluates to type float rather than int. Integers such as 42 lack that fractional marker.
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 →
Same concept, more angles
1 more way this is tested on PCEP
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. Which of the following is a valid floating-point literal in Python?
easy- ✓ A.1e3
- B.'3.14'
- ✓ C.3.14
- D.0xFF
Why A: Both 1e3 and 3.14 are valid floating-point literals in Python. 1e3 uses scientific notation with an exponent, which Python interprets as a float. 3.14 is a literal with a decimal point. Options B and D are string and integer literals, respectively.
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
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.