0

What is the difference between int(input("Enter you number here: ")) and float(input("Enter your Number here: ")).

How and when to use them? Thanks.

29th Dec 2018, 8:11 AM
Adesiyan Joseph
4 Answers
+ 4
Adesiyan Joseph the difference is in the data-type when you use the first one the program expects an integer value as input but in the latter it expects a float value i.e number containing a decimal. External link 🔗 to understand data-type: https://www.programiz.com/JUMP_LINK__&&__python__&&__JUMP_LINK-programming/variables-datatypes
29th Dec 2018, 8:21 AM
Ikechukwu Okonkwo
Ikechukwu Okonkwo - avatar
+ 2
Thanks @iyke4life
29th Dec 2018, 8:36 AM
Adesiyan Joseph
+ 1
The input() method will result in a string type entered by the user. If you expect a number because you want to use it in your program for calculations, you convert it to integer or float type. Which one you need, will depend on the situation (the rest of the code)
29th Dec 2018, 1:14 PM
Tibor Santa
Tibor Santa - avatar
0
Thanks @Tibor
29th Dec 2018, 2:32 PM
Adesiyan Joseph