We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Apply
  • Hiring developers?
  1. Prepare
  2. Python
  3. Regex and Parsing
  4. Detect Floating Point Number

Detect Floating Point Number

Problem
Submissions
Leaderboard
Discussions
Editorial
Tutorial

Check Tutorial tab to know how to to solve.

You are given a string .
Your task is to verify that is a floating point number.

In this task, a valid float number must satisfy all of the following requirements:

Number can start with +, - or . symbol.
For example:
✔+4.50
✔-1.0
✔.5
✔-.7
✔+.4
✖ -+4.5

Number must contain at least decimal value.
For example:
✖ 12.
✔12.0  

Number must have exactly one . symbol.
Number must not give any exceptions when converted using .

Input Format

The first line contains an integer , the number of test cases.
The next line(s) contains a string .

Constraints

Output Format

Output True or False for each test case.

Sample Input 0

4
4.0O0
-1.00
+4.54
SomeRandomStuff

Sample Output 0

False
True
True
False

Explanation 0

: O is not a digit.
: is valid.
: is valid.
SomeRandomStuff: is not a number.

Author

[deleted]

Difficulty

Easy

Max Score

20

Submitted By

63544

Need Help?


View tutorial
View discussions
View editorial
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy