Bird
0
0

Which of the following is the correct way to write a float literal in Python?

easy📝 Syntax Q3 of 15
Python - Data Types as Values

Which of the following is the correct way to write a float literal in Python?

A3.14
B3,14
C'3.14'
D3..14
Step-by-Step Solution
Solution:
  1. Step 1: Identify valid float syntax

    In Python, floats use a dot '.' as the decimal separator without quotes.
  2. Step 2: Evaluate options

    3,14 uses a comma, which is invalid. 3.14 uses a dot correctly. '3.14' is a string, not a float. 3..14 has two dots, which is invalid syntax.
  3. Final Answer:

    3.14 -> Option A
  4. Quick Check:

    Float literal syntax = B [OK]
Quick Trick: Use dot '.' for decimals, no quotes [OK]
Common Mistakes:
MISTAKES
  • Using comma instead of dot
  • Writing floats as strings
  • Double dots in numbers

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes