0

In the program why we typecast in srt then assign in result? what is the means of str?

num1 = float(input("Enter a number: ")) num2 = float(input("Enter another number: ")) result = str(num1 + num2) print("The answer is " + result)

28th May 2020, 4:14 PM
Mohammad Yusuf
Mohammad Yusuf - avatar
2 odpowiedzi
+ 2
str() converts its argument to a string. Since you have a numerical value of float type, of you want to concatenate it to a text, you have to convert it to a string.
28th May 2020, 4:16 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar