KnowledgeBoat Logo

Computer Science

Consider the following code segment:

a = input("Enter the value of a:")
b = input("Enter the value of b:")
print(a + b)

If the user runs the program and enters 11 for a and 9 for b then what will the above code display?

Python Data Handling

20 Likes

Answer

Output
Enter the value of a:11
Enter the value of b:9
119
Explanation

input() function accepts user input as string type. The data type of a and b is string not int so addition operator concatenates them to print 119 instead of 20.

Answered By

14 Likes


Related Questions