Safe Float Print
Python
Easy
2 views
Problem Description
Input is a single token. If it is a number, output it with 2 decimals. Else output 0.00.
Output Format
One number with 2 decimals.
Official Solution
import sys
s=sys.stdin.read().strip()
try:
x=float(s)
sys.stdout.write(f'{x:.2f}')
except Exception:
sys.stdout.write('0.00')
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!