Q. The following code is not giving desired output. We want to input value as 20 and obtain output as 40. Could you pinpoint the problem?


Number = input ( "Enter Number")
DoubleTheNumber = Number * 2
Print (DoubleTheNumber)


Answer :-

The problem is that input() returns value as a string, so the input value 20 is returned as string '20' and not as integer 20. So the output is 2020 in place of required output 40. Also “Print” is not legal statement of Python; it should be “print”.

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post