Im stumped on how this code works (in description) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Im stumped on how this code works (in description)

>>> float(input("Enter a number: ")) + float(input("Enter another number: ")) Enter a number: 40 Enter another number: 2 42.0 I don't understand this at all, and need a thorough explanation. thanks!

2nd Apr 2017, 7:16 PM
Abbie Ruperto
Abbie Ruperto - avatar
1 Answer
+ 1
first get input of the first number. then convert it to a float. so float (input) for the first number gives 40.0 do this for the second number also and it gives 2.0 but the statement is adding both numbers using the "+", so it becomes 40.0 + 2.0 = 42.0
2nd Apr 2017, 7:22 PM
Edward