+ 2
Why can't I concatenate strings and integers?
How can i change this code so I get the needed output? Code : x = float(input("Enter a number - ")) print("\nThe square of the number you have entered is - " + x**2) Output : Enter a number - 14 The square of the number you have entered is - 196.0
4 Respuestas
+ 3
hi !byteCode, try str (x**2) hope this will help you its convert the integer to string
+ 3
If you don't want to convert the answer explicitly to string then,
you can use (,) comma instead of (+) plus in between string and integer to get the desired output.
+ 2
print( "the square of no. you have entered "+str(x**2))
0
The input is a floating type.
Then the output of the final answer is processed in the last statement.
ie squaring .
And the output is displayed.