You could just use float, but if you absolutely must know whether the end user has input an int or a float you could check the input string to see if it contains a '.'
i = input()
if '.' in i:
i = float(i)
i = int(i)
you can just do float(input()) and if the sum is an even number you can make an if statement to print it as an int
since you can pass int values to float it doesnt have to have the .12 at the end it will calculate it as float
You can use the eval() function just instead of int() and float()...
Int function takes the input as integer value wheraes the float function takes it as a decimal value....but if u need to I put both tha values without adding a conditional statements in the code and without eror....you can use the eval() function which stands for evaluate...as it name suggest it evaluates the inputted value...it also supports string values...
a=eval(input ("enter first no :"))
b=eval(input("enter 2nd no :"))
print ("Sum : ",a+b)
Try Here :
You can use eval(), it simple take input that we gave.
'''we can give it any data type but we have to write that data type in its format, foe example giving int 21 or float 23.2, or string 'Yo'(text should be closed in quotes) '''
If you want to make it aspect both float and integer then use float function because we can't do float operation in integer but in float we can do both float and integer operation so use float function