+ 2

What is the difference between non-integers and float values?

When practicing Type Conversion this code appeared: >>> float(input("Enter a number: ")) + float(input("Enter another number: ")) Enter a number: 40 Enter another number: 2 42.0 At the end it specified that if non integers or float numbers are inserted on the code will cause an error, but I tried inserting Enter a number: 30.2 Enter another number 2 and it came out as 32.2 So what is the rule exactly? Can someone explain the difference?

14th Nov 2019, 7:10 PM
Leticia
Leticia - avatar
0 Respuestas