0

# What is the difference between this 2 python calculations

Question 1 a = input("a="). .... value entered 5 b = input("b="). .... value entered 6 c = int(a+b) print (c) answer was 56 I EXPECTED 11 QUESTION 2. a = input("a="). .... value entered 5 b = input("b="). .... value entered 6 c = int(a) + int(b) print (c) answer was 11 which is what I expected why are the answers different?

3 Respostas

+ 1

thanks guys

0

So invariably... the '+' simply place the 2 figures next to each other?

0

Input returns string ,so in first 5 was "5" and 6 was "6" so adding two strings will give 56 and in second method you converted string type to int so it was 11