user_input = input ("Enter the number ")
try:
val = int(user_input)
print("Input is an integer number",val,"\nThe decimal value is 0")
except ValueError:
try:
val = float(user_input)
print("Input is a float number ", val," \nThe decimal value is %.8f"%abs((val-int(val))))
except ValueError:
print("No.. input is not a number. It's a string")
Comments
Leave a comment