What's float for | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What's float for

print(float(input("Enter a number: ")) + float(input("Enter another number: "))) why does it use float?

13th Nov 2016, 10:07 PM
Max
Max - avatar
3 Answers
+ 1
It's also useful for doing something with the user input after like: Calculating taxes. Without float, input would make price equal to a string which would result in an error with you try to multiply it with a floating point number like 1.07 price = float(input("Enter price of product:")) tax = 1.07 total = price * tax print(total)
20th Nov 2016, 2:02 AM
Claska
0
thank you
13th Nov 2016, 10:11 PM
Max
Max - avatar
0
float is a type like integer or string, you can also change it if you want with another type
19th Nov 2016, 6:27 AM
James