Errors while i'm coding

int(a) == input (a)
int(b) == input (b)
int(c) == int((a)+(b))
print(c)

Always gives value 35 .no matter what input we type

a = input (a)
b = input (b)
c = a+b

print(c)

This program code does not give added value. instead input (a)= 5,input (b)= 4

out put comes as 54 and not 9 .

Why is that ?

1 Like

@rudolphreganjoseph.n

For question 2, when you are taking the user input ,you are defining
input(a) this means that input is in string format and two string cannot be added that’s why it is getting concatenated.

If you want to add two values take the user input in int format.

For question 1, you don’t need to define the data type of the variable beforehand in python like int(a).you can define it while taking the input.

1 Like

@rudolphreganjoseph.n
Hello dear,
In both questions you are not using proper programming paradigm as per python.
Please try to program as python logic supports taking user input for out requirements.
In question 01
You can’t definite data type before hand.
In question 02
Try to type cast into integers because input function by default takes string as input.